From ce4d54e75ad44ad2fdb97105af894e39e782ee1d Mon Sep 17 00:00:00 2001 From: Martin Jansa Date: Fri, 17 Sep 2021 20:40:45 +0200 Subject: [PATCH] Jenkins: fix unbound S3_BUCKET_ACL * previous MR was merged so fast that the test build didn't even start before that, fix unbound S3_BUCKET_ACL and counting of BUNDLEs * fix shebangs in upload-bundles*.sh to bash as other scripts are using, we have (useless) "function" bashism inside, so lets not claim /bin/sh compatiblity --- Jenkins/Jenkinsfile-Bundles | 3 +-- Jenkins/Jenkinsfile-Bundles-Release | 3 +-- Jenkins/build-bundles.sh | 5 ++++- Jenkins/upload-bundles-wise.sh | 2 +- Jenkins/upload-bundles.sh | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Jenkins/Jenkinsfile-Bundles b/Jenkins/Jenkinsfile-Bundles index 563317536..46da2589d 100644 --- a/Jenkins/Jenkinsfile-Bundles +++ b/Jenkins/Jenkinsfile-Bundles @@ -44,7 +44,6 @@ pipeline { DISPLAY = ":0" JENKINS_BUILD_ID = "${BUILD_ID}" S3_DOWNLOAD_HOST = "${S3_DOWNLOAD_HOST}/v2" - S3_BUCKET_ACL = "--acl public-read" } stages { @@ -363,7 +362,7 @@ pipeline { withCredentials([[credentialsId: "${S3_CREDENTIALS_ID}", accessKeyVariable: 'AWS_ACCESS_KEY_ID', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY', $class: 'AmazonWebServicesCredentialsBinding']]) { dir("Jenkins") { sh """ - UID=`id -u` docker-compose run --rm upload-bundles | tee ../upload-bundles.log + UID=`id -u` S3_BUCKET_ACL="--acl public-read" docker-compose run --rm upload-bundles | tee ../upload-bundles.log # exit PIPESTATUS[0] cannot be used because of: # groovy.lang.MissingPropertyException: No such property: PIPESTATUS for class: groovy.lang.Binding exit `grep ^upload.failed: ../upload-bundles.log | wc -l` diff --git a/Jenkins/Jenkinsfile-Bundles-Release b/Jenkins/Jenkinsfile-Bundles-Release index 7e839f6e5..9a055d8b9 100644 --- a/Jenkins/Jenkinsfile-Bundles-Release +++ b/Jenkins/Jenkinsfile-Bundles-Release @@ -46,7 +46,6 @@ pipeline { GIT_TAG = "${GIT_TAG}" S3_DOWNLOAD_HOST = "${S3_RELEASE_DOWNLOAD_HOST}" S3_BUCKET_NAME = "${S3_RELEASE_BUCKET_NAME}" - S3_BUCKET_ACL = "" } stages { @@ -365,7 +364,7 @@ pipeline { withCredentials([[credentialsId: "${S3_CREDENTIALS_ID}", accessKeyVariable: 'AWS_ACCESS_KEY_ID', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY', $class: 'AmazonWebServicesCredentialsBinding']]) { dir("Jenkins") { sh """ - UID=`id -u` docker-compose run --rm upload-bundles | tee ../upload-bundles.log + UID=`id -u` S3_BUCKET_ACL="" docker-compose run --rm upload-bundles | tee ../upload-bundles.log # exit PIPESTATUS[0] cannot be used because of: # groovy.lang.MissingPropertyException: No such property: PIPESTATUS for class: groovy.lang.Binding exit `grep ^upload.failed: ../upload-bundles.log | wc -l` diff --git a/Jenkins/build-bundles.sh b/Jenkins/build-bundles.sh index 9752b9024..2cdb0f21e 100755 --- a/Jenkins/build-bundles.sh +++ b/Jenkins/build-bundles.sh @@ -89,7 +89,6 @@ function build_bundle { # Move the source for individual bundles from Assets/External-All to Assets/External # to prevent Unity importing all the available assets when we went to build just one # of them - BUNDLE=$(expr ${BUNDLE} + 1) echo "Building bundle (${BUNDLE}/${BUNDLES}) $*" if [ ! -d .external-assets/$1/$2 ] ; then echo "ERROR: Bundle source doesn't exist in .external-assets/$1/$2" @@ -172,12 +171,14 @@ BUNDLE=0 if [ ! -z ${SIM_ENVIRONMENTS+x} ]; then getAssets "${SIM_ENVIRONMENTS}" for A in ${ASSETS}; do + BUNDLE=$(expr ${BUNDLE} + 1) build_bundle Environments ${A} 2>&1 | tee -a unity-build-bundles-Environments.log done fi if [ ! -z ${SIM_VEHICLES+x} ]; then getAssets "${SIM_VEHICLES}" for A in ${ASSETS}; do + BUNDLE=$(expr ${BUNDLE} + 1) build_bundle Vehicles ${A} 2>&1 | tee -a unity-build-bundles-Vehicles.log done fi @@ -185,6 +186,7 @@ fi if [ ! -z ${SIM_SENSORS+x} ]; then getAssets "${SIM_SENSORS}" for A in ${ASSETS}; do + BUNDLE=$(expr ${BUNDLE} + 1) build_bundle Sensors ${A} 2>&1 | tee -a unity-build-bundles-Sensors.log done fi @@ -192,6 +194,7 @@ fi if [ ! -z ${SIM_BRIDGES+x} ]; then getAssets "${SIM_BRIDGES}" for A in ${ASSETS}; do + BUNDLE=$(expr ${BUNDLE} + 1) build_bundle Bridges ${A} 2>&1 | tee -a unity-build-bundles-Bridges.log done fi diff --git a/Jenkins/upload-bundles-wise.sh b/Jenkins/upload-bundles-wise.sh index d803598bc..b95ae252a 100755 --- a/Jenkins/upload-bundles-wise.sh +++ b/Jenkins/upload-bundles-wise.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash #set -eu #set -x diff --git a/Jenkins/upload-bundles.sh b/Jenkins/upload-bundles.sh index a84e3e158..69e4883b4 100755 --- a/Jenkins/upload-bundles.sh +++ b/Jenkins/upload-bundles.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -eu set -x @@ -18,7 +18,7 @@ function uploadAssets() echo "$1" | while IFS= read -r LINE ; do local ID="${LINE%% *}" local NAME="${LINE#* }" - aws s3 cp ${S3_BUCKET_ACL} "${SOURCE_FOLDER}/${PREFIX}_${NAME}" s3://${S3_BUCKET_NAME}/v2/${ID}/ + aws s3 cp ${S3_BUCKET_ACL=} "${SOURCE_FOLDER}/${PREFIX}_${NAME}" s3://${S3_BUCKET_NAME}/v2/${ID}/ done }