diff --git a/scripts/release/build/stage/build/run.sh b/scripts/release/build/stage/build/run.sh index 87245ee664..62acf252c8 100755 --- a/scripts/release/build/stage/build/run.sh +++ b/scripts/release/build/stage/build/run.sh @@ -2,6 +2,8 @@ set -ex +trap 'bash ./scripts/release/common/ec2/shutdown.sh' ERR + # Path(s) are relative to the root of the Jenkins workspace. ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$(cat scripts/release/common/ec2/tmp/instance)" bash go/src/github.com/algorand/go-algorand/scripts/release/build/stage/build/task.sh diff --git a/scripts/release/build/stage/build/task.sh b/scripts/release/build/stage/build/task.sh index a10955979f..ca8df5ce17 100755 --- a/scripts/release/build/stage/build/task.sh +++ b/scripts/release/build/stage/build/task.sh @@ -33,7 +33,7 @@ fi # Run RPM build in Centos7 Docker container sg docker "docker build -t algocentosbuild - < $HOME/go/src/github.com/algorand/go-algorand/scripts/release/common/docker/centos.Dockerfile" -sg docker "docker run --rm --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/build.sh" +sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/build.sh" echo date "+build_release end BUILD stage %Y%m%d_%H%M%S" diff --git a/scripts/release/build/stage/package/run.sh b/scripts/release/build/stage/package/run.sh index 08e7ed86e1..8bcd9b32cd 100755 --- a/scripts/release/build/stage/package/run.sh +++ b/scripts/release/build/stage/package/run.sh @@ -2,6 +2,8 @@ set -ex +trap 'bash ./scripts/release/common/ec2/shutdown.sh' ERR + # Path(s) are relative to the root of the Jenkins workspace. ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$(cat scripts/release/common/ec2/tmp/instance)" bash go/src/github.com/algorand/go-algorand/scripts/release/build/stage/package/task.sh diff --git a/scripts/release/build/stage/setup/run.sh b/scripts/release/build/stage/setup/run.sh index c35046ef7f..80916a9eee 100755 --- a/scripts/release/build/stage/setup/run.sh +++ b/scripts/release/build/stage/setup/run.sh @@ -3,6 +3,8 @@ set -ex +trap 'bash ./scripts/release/common/ec2/shutdown.sh' ERR + # Path(s) are relative to the root of the Jenkins workspace. BRANCH=$(./scripts/release/util/check_remote.sh "$1") INSTANCE=$(cat ./scripts/release/common/ec2/tmp/instance) diff --git a/scripts/release/build/stage/sign/run.sh b/scripts/release/build/stage/sign/run.sh index 7fd86557e8..4c40ddf67b 100755 --- a/scripts/release/build/stage/sign/run.sh +++ b/scripts/release/build/stage/sign/run.sh @@ -2,6 +2,8 @@ set -ex +trap 'bash ./scripts/release/common/ec2/shutdown.sh' ERR + # Path(s) are relative to the root of the Jenkins workspace. ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$(cat scripts/release/common/ec2/tmp/instance)" bash go/src/github.com/algorand/go-algorand/scripts/release/build/stage/sign/task.sh diff --git a/scripts/release/build/stage/upload/run.sh b/scripts/release/build/stage/upload/run.sh index c96d2d9158..83a7b5d731 100755 --- a/scripts/release/build/stage/upload/run.sh +++ b/scripts/release/build/stage/upload/run.sh @@ -2,6 +2,8 @@ set -ex +trap 'bash ./scripts/release/common/ec2/shutdown.sh' ERR + # Path(s) are relative to the root of the Jenkins workspace. #BUCKET_LOCATION="$2" @@ -15,8 +17,6 @@ rm -rf pkg && mkdir -p pkg/"$FULLVERSION" ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$INSTANCE" bash go/src/github.com/algorand/go-algorand/scripts/release/build/stage/upload/task.sh scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no -r ubuntu@"$INSTANCE":~/node_pkg/* pkg/"$FULLVERSION"/ -# Create the buildlog file. -scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no ubuntu@"$INSTANCE":~/build_status_"$CHANNEL"_*.asc.gz pkg/"$FULLVERSION" #aws s3 sync --exclude dev* --exclude master* --exclude nightly* --exclude stable* --acl public-read pkg/"$FULLVERSION" s3://"$BUCKET_LOCATION"/"$CHANNEL"/"$FULLVERSION"/ aws s3 sync --exclude dev* --exclude master* --exclude nightly* --exclude stable* --acl public-read pkg/"$FULLVERSION" s3://ben-test-2.0.3/"$CHANNEL"/"$FULLVERSION"/ diff --git a/scripts/release/common/ec2/shutdown.sh b/scripts/release/common/ec2/shutdown.sh index 8cc312eeb4..67b5fc5aa5 100755 --- a/scripts/release/common/ec2/shutdown.sh +++ b/scripts/release/common/ec2/shutdown.sh @@ -1,18 +1,12 @@ #!/usr/bin/env bash # shellcheck disable=2164 -AWS_REGION="$1" +AWS_REGION="${1:-us-west-1}" GREEN_FG=$(echo -en "\e[32m") YELLOW_FG=$(echo -en "\e[33m") END_FG_COLOR=$(echo -en "\e[39m") REPO_ROOT="$( cd "$(dirname "$0")" ; pwd -P )" -if [ "$AWS_REGION" = "" ] -then - echo "Missing AWS_REGION argument" - exit 1 -fi - pushd "$REPO_ROOT"/tmp > /dev/null SGID=$(cat sgid) INSTANCE_ID=$(cat instance-id) diff --git a/scripts/release/common/setup.sh b/scripts/release/common/setup.sh index 091a9ae51e..f90b1faf70 100755 --- a/scripts/release/common/setup.sh +++ b/scripts/release/common/setup.sh @@ -7,17 +7,25 @@ if [ -z "${BUILDTIMESTAMP}" ]; then BUILDTIMESTAMP=$(cat "${HOME}/buildtimestamp") export BUILDTIMESTAMP echo run "${0}" with output to "${HOME}/buildlog_${BUILDTIMESTAMP}" - (bash "${0}" "${1}" 2>&1) | tee "${HOME}/buildlog_${BUILDTIMESTAMP}" - exit 0 + bash "${0}" "${1}" 2>&1 | tee "${HOME}/buildlog_${BUILDTIMESTAMP}" + # http://tldp.org/LDP/abs/html/internalvariables.html#PIPESTATUSREF + exit "${PIPESTATUS[0]}" fi echo date "+build_release begin SETUP stage %Y%m%d_%H%M%S" echo +# `apt-get` fails randomly when downloading package, this is a hack that "works" reasonably well. +echo -e "deb http://us.archive.ubuntu.com/ubuntu/ bionic main universe multiverse\ndeb http://archive.ubuntu.com/ubuntu/ bionic main universe multiverse" | sudo tee /etc/apt/sources.list.d/ubuntu + sudo apt-get update sudo apt-get upgrade -y -sudo apt-get install -y build-essential automake autoconf awscli docker.io git gpg nfs-common python3 rpm sqlite3 python3-boto3 g++ libtool rng-tools + +# `apt-get` fails randomly when downloading package, this is a hack that "works" reasonably well. +sudo apt-get update + +sudo apt-get install -y build-essential automake autoconf awscli docker.io git gpg nfs-common python python3 rpm sqlite3 python3-boto3 g++ libtool rng-tools sudo rngd -r /dev/urandom #umask 0077 diff --git a/scripts/release/prod/stage/setup/run.sh b/scripts/release/prod/stage/setup/run.sh index dcfe9f8067..9485a2f839 100755 --- a/scripts/release/prod/stage/setup/run.sh +++ b/scripts/release/prod/stage/setup/run.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash # shellcheck disable=2029 +set -ex + +trap 'bash ./scripts/release/common/ec2/shutdown.sh' ERR + # Path(s) are relative to the root of the Jenkins workspace. INSTANCE=$(cat scripts/release/common/ec2/tmp/instance) #BUCKET="$1" diff --git a/scripts/release/prod/stage/sync/run.sh b/scripts/release/prod/stage/sync/run.sh index c492a509bb..b22a94b147 100755 --- a/scripts/release/prod/stage/sync/run.sh +++ b/scripts/release/prod/stage/sync/run.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash # shellcheck disable=2029 +set -ex + +trap 'bash ./scripts/release/common/ec2/shutdown.sh' ERR + # Path(s) are relative to the root of the Jenkins workspace. STAGING="$1" PROD="$2" diff --git a/scripts/release/test/deb/run_ubuntu.sh b/scripts/release/test/deb/run_ubuntu.sh index 0ea99246eb..8d1cab29ba 100755 --- a/scripts/release/test/deb/run_ubuntu.sh +++ b/scripts/release/test/deb/run_ubuntu.sh @@ -1,6 +1,4 @@ #!/usr/bin/env bash -# -# This script exists to give a trap atexit context for killing the httpd so that we're not waiting on that set -ex diff --git a/scripts/release/test/stage/setup/run.sh b/scripts/release/test/stage/setup/run.sh index c2f905cdb2..180c09fbf8 100755 --- a/scripts/release/test/stage/setup/run.sh +++ b/scripts/release/test/stage/setup/run.sh @@ -3,6 +3,8 @@ set -ex +trap 'bash ./scripts/release/common/ec2/shutdown.sh' ERR + # Path(s) are relative to the root of the Jenkins workspace. INSTANCE=$(cat scripts/release/common/ec2/tmp/instance) BRANCH="$1" diff --git a/scripts/release/test/stage/test/run.sh b/scripts/release/test/stage/test/run.sh index 24e6c41fd1..1107fe7cab 100755 --- a/scripts/release/test/stage/test/run.sh +++ b/scripts/release/test/stage/test/run.sh @@ -2,6 +2,8 @@ set -ex +trap 'bash ./scripts/release/common/ec2/shutdown.sh' ERR + # Path(s) are relative to the root of the Jenkins workspace. INSTANCE=$(cat scripts/release/common/ec2/tmp/instance)