From a2db3fb17b4c2c27381a20b02d192f9737ce09fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= Date: Mon, 3 Apr 2023 15:27:45 +0200 Subject: [PATCH] kokoro: always chown files (#5186) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the build fails, the artifacts must still be chowned so the CI can pick them up. If they are not, the CI tooling will fail and go into 'aborted' state, which blocks the logs. Signed-off-by: Nathan Gauër --- kokoro/scripts/linux/build.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/kokoro/scripts/linux/build.sh b/kokoro/scripts/linux/build.sh index 85d4b61ab..688ba7933 100644 --- a/kokoro/scripts/linux/build.sh +++ b/kokoro/scripts/linux/build.sh @@ -26,6 +26,18 @@ COMPILER=$2 TOOL=$3 BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} +# chown the given directory to the current user, if it exists. +# Docker creates files with the root user - this can upset the Kokoro artifact copier. +function chown_dir() { + dir=$1 + if [[ -d "$dir" ]]; then + sudo chown -R "$(id -u):$(id -g)" "$dir" + fi +} + +set +e +# Allow build failures + # "--privileged" is required to run ptrace in the asan builds. docker run --rm -i \ --privileged \ @@ -41,16 +53,11 @@ docker run --rm -i \ --env BUILD_SHA="${BUILD_SHA}" \ --entrypoint "${SCRIPT_DIR}/build-docker.sh" \ "gcr.io/shaderc-build/radial-build:latest" +RESULT=$? - -# chown the given directory to the current user, if it exists. -# Docker creates files with the root user - this can upset the Kokoro artifact copier. -function chown_dir() { - dir=$1 - if [[ -d "$dir" ]]; then - sudo chown -R "$(id -u):$(id -g)" "$dir" - fi -} - +# This is important. If the permissions are not fixed, kokoro will fail +# to pull build artifacts, and put the build in tool-failure state, which +# blocks the logs. chown_dir "${ROOT_DIR}/build" chown_dir "${ROOT_DIR}/external" +exit $RESULT