diff --git a/hack/jenkins/e2e-runner.sh b/hack/jenkins/e2e-runner.sh index d676f54a925..7a5a37eea4f 100755 --- a/hack/jenkins/e2e-runner.sh +++ b/hack/jenkins/e2e-runner.sh @@ -115,6 +115,11 @@ fi cd kubernetes +# Upload build start time and k8s version to GCS, but not on PR Jenkins. +if [[ ! "${JOB_NAME}" =~ -pull- ]]; then + bash <(curl -fsS --retry 3 "https://raw.githubusercontent.com/kubernetes/kubernetes/master/hack/jenkins/upload-started.sh") +fi + # Have cmd/e2e run by goe2e.sh generate JUnit report in ${WORKSPACE}/junit*.xml ARTIFACTS=${WORKSPACE}/_artifacts mkdir -p ${ARTIFACTS} diff --git a/hack/jenkins/job-configs/global.yaml b/hack/jenkins/job-configs/global.yaml index 6a04d685291..acb28b4f8b5 100644 --- a/hack/jenkins/job-configs/global.yaml +++ b/hack/jenkins/job-configs/global.yaml @@ -29,6 +29,33 @@ else curl -fsS --retry 3 "https://raw.githubusercontent.com/kubernetes/kubernetes/master/hack/jenkins/upload-to-gcs.sh" | bash - fi + - shell: | + curl -fsS --retry 3 "https://raw.githubusercontent.com/kubernetes/kubernetes/master/hack/jenkins/upload-finished.sh" > upload-finished.sh + chmod +x upload-finished.sh + - conditional-step: + condition-kind: current-status + condition-worst: SUCCESS + condition-best: SUCCESS + steps: + - shell: './upload-finished.sh SUCCESS' + - conditional-step: + condition-kind: current-status + condition-worst: UNSTABLE + condition-best: UNSTABLE + steps: + - shell: './upload-finished.sh UNSTABLE' + - conditional-step: + condition-kind: current-status + condition-worst: FAILURE + condition-best: FAILURE + steps: + - shell: './upload-finished.sh FAILURE' + - conditional-step: + condition-kind: current-status + condition-worst: ABORTED + condition-best: ABORTED + steps: + - shell: './upload-finished.sh ABORTED' script-only-if-succeeded: False script-only-if-failed: False diff --git a/hack/jenkins/job-configs/kubernetes-build.yaml b/hack/jenkins/job-configs/kubernetes-build.yaml index d41dafcf1f1..29d790f0b54 100644 --- a/hack/jenkins/job-configs/kubernetes-build.yaml +++ b/hack/jenkins/job-configs/kubernetes-build.yaml @@ -4,6 +4,7 @@ logrotate: numToKeep: 200 builders: + - shell: 'bash <(curl -fsS --retry 3 "https://raw.githubusercontent.com/kubernetes/kubernetes/master/hack/jenkins/upload-started.sh")' - shell: './hack/jenkins/build.sh' properties: - mail-watcher diff --git a/hack/jenkins/job-configs/kubernetes-test-go.yaml b/hack/jenkins/job-configs/kubernetes-test-go.yaml index 45e3b8475df..e1635f5ffba 100644 --- a/hack/jenkins/job-configs/kubernetes-test-go.yaml +++ b/hack/jenkins/job-configs/kubernetes-test-go.yaml @@ -7,6 +7,7 @@ numToKeep: 200 node: unittest builders: + - shell: 'bash <(curl -fsS --retry 3 "https://raw.githubusercontent.com/kubernetes/kubernetes/master/hack/jenkins/upload-started.sh")' - shell: './hack/jenkins/gotest-dockerized.sh' publishers: - claim-build diff --git a/hack/jenkins/upload-finished.sh b/hack/jenkins/upload-finished.sh new file mode 100755 index 00000000000..cb864a169e8 --- /dev/null +++ b/hack/jenkins/upload-finished.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Copyright 2016 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# This is meant to be run at the end of every Jenkins job. +# +# Pass in the result of the build in $1. This will upload that, along with the +# current time, to GCS. + +set -o errexit +set -o nounset +set -o pipefail + +if [[ $# -ne 1 ]]; then + echo "Usage: hack/jenkins/upload-finished.sh RESULT" >&2 + exit 1 +fi + +readonly result="$1" +readonly timestamp=$(date +%s) +readonly location="gs://kubernetes-jenkins/logs/${JOB_NAME}/${BUILD_NUMBER}/finished.json" + +echo "Uploading build result to: ${location}" +gsutil -q cp -a "public-read" <( + echo "{" + echo " \"result\": \"${result}\"," + echo " \"timestamp\": ${timestamp}" + echo "}" +) "${location}" diff --git a/hack/jenkins/upload-started.sh b/hack/jenkins/upload-started.sh new file mode 100755 index 00000000000..9ef612af029 --- /dev/null +++ b/hack/jenkins/upload-started.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Copyright 2016 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# This is meant to be run at the start of every Jenkins job. +# +# Discovers the local kubernetes version and uploads it, along with +# the current time, to GCS. + +set -o errexit +set -o nounset +set -o pipefail + +version="" +readonly timestamp=$(date +%s) +readonly location="gs://kubernetes-jenkins/logs/${JOB_NAME}/${BUILD_NUMBER}/started.json" + +# Try to discover the kubernetes version. +if [[ -e "version" ]]; then + version=$(cat "version") +elif [[ -e "hack/lib/version.sh" ]]; then + version=$( + export KUBE_ROOT="." + source "hack/lib/version.sh" + kube::version::get_version_vars + echo "${KUBE_GIT_VERSION-}" + ) +fi + +if [[ -n "${version}" ]]; then + echo "Found Kubernetes version: ${version}" +else + echo "Could not find Kubernetes version" +fi + +echo "Uploading version to: ${location}" +gsutil -q cp -a "public-read" <( + echo "{" + echo " \"version\": \"${version}\"," + echo " \"timestamp\": ${timestamp}" + echo "}" +) "${location}"