diff --git a/hack/jenkins/upload-to-gcs.sh b/hack/jenkins/upload-to-gcs.sh index 81d805c8fe2..13c5fafb39b 100755 --- a/hack/jenkins/upload-to-gcs.sh +++ b/hack/jenkins/upload-to-gcs.sh @@ -156,23 +156,23 @@ function update_job_result_cache() { for upload_attempt in $(seq 3); do echo "Copying ${job_results} to ${tmp_results} (attempt ${upload_attempt})" + # The sed construct below is stripping out only the "version" lines + # and then ensuring there's a single comma at the end of the line. gsutil -q cat ${job_results} 2>&- |\ - sed -n 's/^\({"version".*}\),*/\1,/p' >> ${tmp_results} || continue - + sed -n 's/^\({"version".*}\),*/\1,/p' |\ + tail -${cache_size} >> ${tmp_results} || continue break done echo "{\"version\": \"${version}\", \"buildnumber\": \"${BUILD_NUMBER}\"," \ "\"result\": \"${build_result}\"}" >> ${tmp_results} - # JSON doesn't like terminating elements to contain a "," separator, so - # terminate the elements with an empty one. - echo -e "{}\n]" >> ${tmp_results} + echo "]" >> ${tmp_results} for upload_attempt in $(seq 3); do echo "Copying ${tmp_results} to ${job_results} (attempt ${upload_attempt})" gsutil -q -h "Content-Type:application/json" cp -a "${gcs_acl}" \ - <(tail -${cache_size} ${tmp_results}) ${job_results} || continue + ${tmp_results} ${job_results} || continue break done