From f03b3c9171acbc9dce2f6bf4d292c884aebc5849 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Mon, 2 Nov 2015 17:26:45 -0800 Subject: [PATCH 1/3] Print out URL of where to find uploaded logs and artifacts. --- hack/jenkins/upload-to-gcs.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hack/jenkins/upload-to-gcs.sh b/hack/jenkins/upload-to-gcs.sh index aa937ed2462..79eef11116b 100755 --- a/hack/jenkins/upload-to-gcs.sh +++ b/hack/jenkins/upload-to-gcs.sh @@ -72,6 +72,8 @@ function upload_logs_to_gcs() { cp -a "${gcs_acl}" - "${gcs_job_path}/latest-build.txt" || continue break # all uploads succeeded if we hit this point done + local -r results_url=${gcs_build_path//"gs:/"/"https://storage.cloud.google.com"} + echo -e "\n\n\n*** View logs and artifacts at ${results_url} ***\n\n" } # Automatically upload logs to GCS on exit or timeout. From 6bd450ba052ef0fbd27c4c49a14d363cc8d0f3a1 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Mon, 2 Nov 2015 17:34:07 -0800 Subject: [PATCH 2/3] Update comment on how to use script --- hack/jenkins/upload-to-gcs.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hack/jenkins/upload-to-gcs.sh b/hack/jenkins/upload-to-gcs.sh index 79eef11116b..5a8542f34c9 100755 --- a/hack/jenkins/upload-to-gcs.sh +++ b/hack/jenkins/upload-to-gcs.sh @@ -17,10 +17,13 @@ # Source this script in the Jenkins "Execute shell" build action to have all # test artifacts and the console log uploaded at the end of the test run. -# For example, you might use the following line as the first command: -# mkdir -p _tmp/ && curl -fsS --retry 3 -o _tmp/upload-to-gcs.sh \ -# "https://raw.githubusercontent.com/kubernetes/kubernetes/master/hack/jenkins/upload-to-gcs.sh" \ -# && source _tmp/upload-to-gcs.sh +# For example, you might use the following snippet as the first few lines: +# +# if [[ -f ./hack/jenkins/upload-to-gcs.sh ]]; then +# source ./hack/jenkins/upload-to-gcs.sh +# else +# curl -fsS -o upload-to-gcs.sh --retry 3 "https://raw.githubusercontent.com/kubernetes/kubernetes/master/hack/jenkins/upload-to-gcs.sh" && source upload-to-gcs.sh; rm -f upload-to-gcs.sh +# fi # Note that this script requires the Jenkins shell binary to be set to bash, not # the system default (which may be dash on Debian-based systems). From 10bcd3ef36248f0a59116947c201b1c011c51090 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Tue, 3 Nov 2015 18:03:59 -0800 Subject: [PATCH 3/3] Don't fail if the console log doesn't exist. --- hack/jenkins/upload-to-gcs.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hack/jenkins/upload-to-gcs.sh b/hack/jenkins/upload-to-gcs.sh index 5a8542f34c9..265c4f060d1 100755 --- a/hack/jenkins/upload-to-gcs.sh +++ b/hack/jenkins/upload-to-gcs.sh @@ -61,12 +61,16 @@ function upload_logs_to_gcs() { gsutil -m -q -o "GSUtil:use_magicfile=True" cp -a "${gcs_acl}" -r -c \ -z log,txt,xml "${artifacts_path}" "${gcs_build_path}/artifacts" || continue fi - # Remove ANSI escape sequences from the console log before uploading. - local -r filtered_console_log="${WORKSPACE}/console-log.txt" - sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" \ - "${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/log" \ - > "${filtered_console_log}" - gsutil -q cp -a "${gcs_acl}" -z txt "${filtered_console_log}" "${gcs_build_path}/" || continue + local -r console_log="${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/log" + # The console log only exists on the Jenkins master, so don't fail if it + # doesn't exist. + if [[ -f "${console_log}" ]]; then + # Remove ANSI escape sequences from the console log before uploading. + local -r filtered_console_log="${WORKSPACE}/console-log.txt" + sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" \ + "${console_log}" > "${filtered_console_log}" + gsutil -q cp -a "${gcs_acl}" -z txt "${filtered_console_log}" "${gcs_build_path}/" || continue + fi # Mark this build as the latest completed. { echo "BUILD_NUMBER=${BUILD_NUMBER}"