#!/bin/bash cp /home/travis/.m2/passed_settings.xml /home/travis/.m2/settings.xml if [[ -s //etc/profile ]]; then source //etc/profile fi if [[ -s $HOME/.bash_profile ]] ; then source $HOME/.bash_profile fi ANSI_RED="\033[31;1m" ANSI_GREEN="\033[32;1m" ANSI_RESET="\033[0m" ANSI_CLEAR="\033[0K" if [ $TERM = dumb ]; then unset TERM fi : "${SHELL:=/bin/bash}" : "${TERM:=xterm}" : "${USER:=travis}" export SHELL export TERM export USER TRAVIS_TEST_RESULT= TRAVIS_CMD= travis_cmd() { local assert output display retry timing cmd result secure cmd=$1 TRAVIS_CMD=$cmd shift while true; do case "$1" in --assert) assert=true; shift ;; --echo) output=true; shift ;; --display) display=$2; shift 2;; --retry) retry=true; shift ;; --timing) timing=true; shift ;; --secure) secure=" 2>/dev/null"; shift ;; *) break ;; esac done if [[ -n "$timing" ]]; then travis_time_start fi if [[ -n "$output" ]]; then echo "\$ ${display:-$cmd}" fi if [[ -n "$retry" ]]; then travis_retry eval "$cmd $secure" result=$? else if [[ -n "$secure" ]]; then eval "$cmd $secure" 2>/dev/null else eval "$cmd $secure" fi result=$? if [[ -n $secure && $result -ne 0 ]]; then echo -e "${ANSI_RED}The previous command failed, possibly due to a malformed secure environment variable.${ANSI_CLEAR} ${ANSI_RED}Please be sure to escape special characters such as ' ' and '$'.${ANSI_CLEAR} ${ANSI_RED}For more information, see https://docs.travis-ci.com/user/encryption-keys.${ANSI_CLEAR}" fi fi if [[ -n "$timing" ]]; then travis_time_finish fi if [[ -n "$assert" ]]; then travis_assert $result fi return $result } travis_time_start() { travis_timer_id=$(printf %08x $(( RANDOM * RANDOM ))) travis_start_time=$(travis_nanoseconds) echo -en "travis_time:start:$travis_timer_id\r${ANSI_CLEAR}" } travis_time_finish() { local result=$? travis_end_time=$(travis_nanoseconds) local duration=$(($travis_end_time-$travis_start_time)) echo -en "\ntravis_time:end:$travis_timer_id:start=$travis_start_time,finish=$travis_end_time,duration=$duration\r${ANSI_CLEAR}" return $result } travis_nanoseconds() { local cmd="date" local format="+%s%N" local os=$(uname) if hash gdate > /dev/null 2>&1; then cmd="gdate" elif [[ "$os" = Darwin ]]; then format="+%s000000000" fi $cmd -u $format } travis_internal_ruby() { if ! type rvm &>/dev/null; then source $HOME/.rvm/scripts/rvm &>/dev/null fi local i selected_ruby rubies_array rubies_array_sorted rubies_array_len rubies_array=( $( rvm list strings \ | while read -r v; do if [[ ! "${v}" =~ ^ruby-(2\.[0-2]\.[0-9]|1\.9\.3) ]]; then continue fi v="${v//ruby-/}" v="${v%%-*}" echo "$(vers2int "${v}")_${v}" done ) ) bash_qsort_numeric "${rubies_array[@]}" rubies_array_sorted=( ${bash_qsort_numeric_ret[@]} ) rubies_array_len="${#rubies_array_sorted[@]}" i=$(( rubies_array_len - 1 )) selected_ruby="${rubies_array_sorted[${i}]}" selected_ruby="${selected_ruby##*_}" echo "${selected_ruby:-default}" } travis_assert() { local result=${1:-$?} if [ $result -ne 0 ]; then echo -e "\n${ANSI_RED}The command \"$TRAVIS_CMD\" failed and exited with $result during $TRAVIS_STAGE.${ANSI_RESET}\n\nYour build has been stopped." travis_terminate 2 fi } travis_result() { local result=$1 export TRAVIS_TEST_RESULT=$(( ${TRAVIS_TEST_RESULT:-0} | $(($result != 0)) )) if [ $result -eq 0 ]; then echo -e "\n${ANSI_GREEN}The command \"$TRAVIS_CMD\" exited with $result.${ANSI_RESET}" else echo -e "\n${ANSI_RED}The command \"$TRAVIS_CMD\" exited with $result.${ANSI_RESET}" fi } travis_terminate() { pkill -9 -P $$ &> /dev/null || true exit $1 } travis_wait() { local timeout=$1 if [[ $timeout =~ ^[0-9]+$ ]]; then shift else timeout=20 fi local cmd="$@" local log_file=travis_wait_$$.log $cmd &>$log_file & local cmd_pid=$! travis_jigger $! $timeout $cmd & local jigger_pid=$! local result { wait $cmd_pid 2>/dev/null result=$? ps -p$jigger_pid &>/dev/null && kill $jigger_pid } if [ $result -eq 0 ]; then echo -e "\n${ANSI_GREEN}The command $cmd exited with $result.${ANSI_RESET}" else echo -e "\n${ANSI_RED}The command $cmd exited with $result.${ANSI_RESET}" fi echo -e "\n${ANSI_GREEN}Log:${ANSI_RESET}\n" cat $log_file return $result } travis_jigger() { local cmd_pid=$1 shift local timeout=$1 shift local count=0 echo -e "\n" while [ $count -lt $timeout ]; do count=$(($count + 1)) echo -ne "Still running ($count of $timeout): $@\r" sleep 60 done echo -e "\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"$@\"${ANSI_RESET}\n" kill -9 $cmd_pid } travis_retry() { local result=0 local count=1 while [ $count -le 3 ]; do [ $result -ne 0 ] && { echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2 } "$@" result=$? [ $result -eq 0 ] && break count=$(($count + 1)) sleep 1 done [ $count -gt 3 ] && { echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2 } return $result } travis_fold() { local action=$1 local name=$2 echo -en "travis_fold:${action}:${name}\r${ANSI_CLEAR}" } decrypt() { echo $1 | base64 -d | openssl rsautl -decrypt -inkey $HOME/.ssh/id_rsa.repo } vers2int() { printf '1%03d%03d%03d%03d' $(echo "$1" | tr '.' ' ') } bash_qsort_numeric() { local pivot i smaller=() larger=() bash_qsort_numeric_ret=() (($#==0)) && return 0 pivot=${1} shift for i; do if [[ ${i%%_*} -lt ${pivot%%_*} ]]; then smaller+=( "$i" ) else larger+=( "$i" ) fi done bash_qsort_numeric "${smaller[@]}" smaller=( "${bash_qsort_numeric_ret[@]}" ) bash_qsort_numeric "${larger[@]}" larger=( "${bash_qsort_numeric_ret[@]}" ) bash_qsort_numeric_ret=( "${smaller[@]}" "$pivot" "${larger[@]}" ) } if [[ -f /etc/apt/sources.list.d/rabbitmq-source.list ]] ; then sudo rm -f /etc/apt/sources.list.d/rabbitmq-source.list fi mkdir -p $HOME/build cd $HOME/build travis_fold start system_info echo -e "\033[33;1mBuild system information\033[0m" echo -e "Build language: java" echo -e "Build group: stable" echo -e "Build dist: precise" echo -e "Build id: ''" echo -e "Job id: ''" if [[ -f /usr/share/travis/system_info ]]; then cat /usr/share/travis/system_info fi travis_fold end system_info echo sudo rm -rf /var/lib/apt/lists/* for f in $(grep -l rwky/redis /etc/apt/sources.list.d/*); do sed 's,rwky/redis,rwky/ppa,g' $f > /tmp/${f##**/} sudo mv /tmp/${f##**/} /etc/apt/sources.list.d done sudo apt-get update -qq 2>&1 >/dev/null export PATH=$(echo $PATH | sed -e 's/::/:/g') export PATH=$(echo -n $PATH | perl -e 'print join(":", grep { not $seen{$_}++ } split(/:/, scalar <>))') echo "options rotate options timeout:1 nameserver 8.8.8.8 nameserver 8.8.4.4 nameserver 208.67.222.222 nameserver 208.67.220.220 " | sudo tee /etc/resolv.conf &> /dev/null sudo sed -e 's/^\(127\.0\.0\.1.*\)$/\1 '`hostname`'/' -i'.bak' /etc/hosts sudo sed -e 's/^\([0-9a-f:]\+\) localhost/\1/' -i'.bak' /etc/hosts test -f /etc/mavenrc && sudo sed -e 's/M2_HOME=\(.\+\)$/M2_HOME=${M2_HOME:-\1}/' -i'.bak' /etc/mavenrc if [ $(command -v sw_vers) ]; then echo "Fix WWDRCA Certificate" sudo security delete-certificate -Z 0950B6CD3D2F37EA246A1AAA20DFAADBD6FE1F75 /Library/Keychains/System.keychain wget -q https://developer.apple.com/certificationauthority/AppleWWDRCA.cer sudo security add-certificates -k /Library/Keychains/System.keychain AppleWWDRCA.cer fi grep '^127\.0\.0\.1' /etc/hosts | sed -e 's/^127\.0\.0\.1 \(.*\)/\1/g' | sed -e 's/localhost \(.*\)/\1/g' | tr "\n" " " > /tmp/hosts_127_0_0_1 sed '/^127\.0\.0\.1/d' /etc/hosts > /tmp/hosts_sans_127_0_0_1 cat /tmp/hosts_sans_127_0_0_1 | sudo tee /etc/hosts > /dev/null echo -n "127.0.0.1 localhost " | sudo tee -a /etc/hosts > /dev/null cat /tmp/hosts_127_0_0_1 | sudo tee -a /etc/hosts > /dev/null # apply :home_paths for path_entry in $HOME/.local/bin $HOME/bin ; do if [[ ${PATH%%:*} != $path_entry ]] ; then export PATH="$path_entry:$PATH" fi done if [ ! $(uname|grep Darwin) ]; then echo update_initramfs=no | sudo tee -a /etc/initramfs-tools/update-initramfs.conf > /dev/null; fi if [[ "$(sw_vers -productVersion 2>/dev/null | cut -d . -f 2)" -lt 12 ]]; then mkdir -p $HOME/.ssh chmod 0700 $HOME/.ssh touch $HOME/.ssh/config echo -e "Host * UseRoaming no " | cat - $HOME/.ssh/config > $HOME/.ssh/config.tmp && mv $HOME/.ssh/config.tmp $HOME/.ssh/config fi function travis_debug() { echo -e "\033[31;1mThe debug environment is not available. Please contact support.\033[0m" false } if [[ $(command -v sw_vers) ]]; then travis_cmd rvm\ use --echo fi if [[ -L /usr/lib/jvm/java-8-oracle-amd64 ]]; then echo -e "Removing symlink /usr/lib/jvm/java-8-oracle-amd64" travis_cmd sudo\ rm\ -f\ /usr/lib/jvm/java-8-oracle-amd64 --echo if [[ -f $HOME/.jdk_switcher_rc ]]; then echo -e "Reload jdk_switcher" travis_cmd source\ \$HOME/.jdk_switcher_rc --echo fi if [[ -f /opt/jdk_switcher/jdk_switcher.sh ]]; then echo -e "Reload jdk_switcher" travis_cmd source\ /opt/jdk_switcher/jdk_switcher.sh --echo fi fi travis_cmd jdk_switcher\ use\ openjdk7 --assert --echo export GIT_ASKPASS=echo travis_cmd cd\ passed/google/auto --assert --echo if [[ -f .gitmodules ]]; then travis_fold start git.submodule echo Host\ github.com' '\ StrictHostKeyChecking\ no' ' >> ~/.ssh/config travis_cmd git\ submodule\ update\ --init\ --recursive --assert --echo --retry --timing travis_fold end git.submodule fi rm -f ~/.ssh/source_rsa export PS4=+ export TRAVIS=true export CI=true export CONTINUOUS_INTEGRATION=true export PAGER=cat export HAS_JOSH_K_SEAL_OF_APPROVAL=true export TRAVIS_ALLOW_FAILURE='' export TRAVIS_EVENT_TYPE='' export TRAVIS_PULL_REQUEST=false export TRAVIS_SECURE_ENV_VARS=false export TRAVIS_BUILD_ID='' export TRAVIS_BUILD_NUMBER='' export TRAVIS_BUILD_DIR=$HOME/build/passed/google/auto export TRAVIS_JOB_ID='' export TRAVIS_JOB_NUMBER='' export TRAVIS_BRANCH='' export TRAVIS_COMMIT='' export TRAVIS_COMMIT_MESSAGE=$(git log --format=%B -n 1) export TRAVIS_COMMIT_RANGE='' export TRAVIS_REPO_SLUG=google/auto export TRAVIS_OS_NAME=linux export TRAVIS_LANGUAGE=java export TRAVIS_TAG='' export TRAVIS_SUDO=true export TRAVIS_PULL_REQUEST_BRANCH='' export TRAVIS_PULL_REQUEST_SHA='' export TRAVIS_PULL_REQUEST_SLUG='' echo echo -e "\033[33;1mSetting environment variables from .travis.yml\033[0m" travis_cmd export\ CI_DEPLOY_USERNAME\=\[secure\] --echo travis_cmd export\ CI_DEPLOY_PASSWORD\=\[secure\] --echo travis_cmd export\ GH_TOKEN\=\[secure\] --echo echo export TRAVIS_JDK_VERSION=openjdk7 if [[ -f build.gradle ]]; then travis_cmd export\ TERM\=dumb --echo fi find $HOME/.ivy2 -name ivydata-*.properties -delete 2>/dev/null find $HOME/.sbt -name *.lock -delete 2>/dev/null travis_cmd java\ -Xmx32m\ -version --echo travis_cmd javac\ -J-Xmx32m\ -version --echo travis_fold start install travis_cmd mvn\ -Dhttps.protocols=TLSv1.2\ -B\ -U\ -f\ build.pom.xml\ dependency:go-offline\ test\ clean\ --quiet\ --fail-never\ -DskipTests\=true --assert --echo --timing travis_fold end install travis_cmd mvn\ -Dhttps.protocols=TLSv1.2\ -B\ -U\ -f\ build-pom.xml\ verify\ --fail-at-end\ -Dsource.skip\=true\ -Dmaven.javadoc.skip\=true --echo --timing travis_result $? if [[ $TRAVIS_TEST_RESULT = 0 ]]; then travis_fold start after_success.1 travis_cmd util/generate-latest-docs.sh --echo --timing travis_fold end after_success.1 travis_fold start after_success.2 travis_cmd util/publish-snapshot-on-commit.sh --echo --timing travis_fold end after_success.2 fi echo -e "\nDone. Your build exited with $TRAVIS_TEST_RESULT." travis_terminate $TRAVIS_TEST_RESULT