From 9b7f347e934c134a88d14b19315e363183611306 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Thu, 22 Sep 2016 16:03:27 -0700 Subject: [PATCH] Make upload-to-gcs.sh use a different prefix for tests in other repos. For kubernetes/test-infra#476. Also, put the repo in the build metadata so Gubernator can link to the right thing for postsubmit jobs. For PR #$NUM in a given repo, the logs will go to these places: kubernetes/kubernetes => /pr-logs/pull/$NUM kubernetes/test-infra => /pr-logs/pull/test-infra/$NUM google/cadvisor => /pr-logs/pull/google_cadvisor/$NUM Tested with a manual harness. Note that this leaves the latest/indirect untouched as well as postsubmit jobs-- *job names* are still unique, the main issue was that PR numbers might collide. Disturbing as little structure as possible reduces how many things will break. --- hack/jenkins/upload-to-gcs.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/hack/jenkins/upload-to-gcs.sh b/hack/jenkins/upload-to-gcs.sh index 5c099dbde28..ab7df7666be 100755 --- a/hack/jenkins/upload-to-gcs.sh +++ b/hack/jenkins/upload-to-gcs.sh @@ -46,8 +46,31 @@ if [[ ! ${JENKINS_UPLOAD_TO_GCS:-y} =~ ^[yY]$ ]]; then exit 0 fi +# Attempt to determine if we're running against a repo other than +# kubernetes/kubernetes to determine whether to place PR logs in a different +# location. +# +# In the current CI system, the tracked repo is named remote. This is not true +# in general for most devs, where origin and upstream are more common. +GCS_SUBDIR="" +readonly remote_git_repo=$(git config --get remote.remote.url | sed 's:.*github.com/::' || true) +if [[ -n "${remote_git_repo}" ]]; then + case "${remote_git_repo}" in + # main repo: nothing extra + kubernetes/kubernetes) GCS_SUBDIR="" ;; + # a different repo on the k8s org: just the repo name (strip kubernetes/) + kubernetes/*) GCS_SUBDIR="${remote_git_repo#kubernetes/}/" ;; + # any other repo: ${org}_${repo} (replace / with _) + *) GCS_SUBDIR="${remote_git_repo/\//_}/" ;; + esac + if [[ "${remote_git_repo}" != "kubernetes/kubernetes" ]]; then + # also store the repo in started.json, so Gubernator can link it properly. + export BUILD_METADATA_REPO="${remote_git_repo}" + fi +fi + if [[ ${JOB_NAME} =~ -pull- ]]; then - : ${JENKINS_GCS_LOGS_PATH:="gs://kubernetes-jenkins/pr-logs/pull/${ghprbPullId:-unknown}"} + : ${JENKINS_GCS_LOGS_PATH:="gs://kubernetes-jenkins/pr-logs/pull/${GCS_SUBDIR}${ghprbPullId:-unknown}"} : ${JENKINS_GCS_LATEST_PATH:="gs://kubernetes-jenkins/pr-logs/directory"} : ${JENKINS_GCS_LOGS_INDIRECT:="gs://kubernetes-jenkins/pr-logs/directory/${JOB_NAME}"} else