From: Luis Gomez Date: Mon, 4 Jun 2018 16:20:34 +0000 (-0700) Subject: Allow any project/branch to deploy jjb jobs X-Git-Tag: v0.21.0~30^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F64%2F10964%2F2;p=releng%2Fglobal-jjb.git Allow any project/branch to deploy jjb jobs This allows users to trigger the jjb-deploy job from any Gerrit patch. It works in 2 different ways: 1. Triggered from ci-management patch 2. Triggered from non-ci-management patch In case 1) it will deploy whatever is from the ci-management patch. In case 2) it will instead deploy from HEAD of master in the ci-management repo. Change-Id: I414b053a68a105aa4cdc1ab99df9cd9962a080b9 Signed-off-by: Luis Gomez --- diff --git a/jjb/lf-ci-jobs.yaml b/jjb/lf-ci-jobs.yaml index 24f6b696..668342a3 100644 --- a/jjb/lf-ci-jobs.yaml +++ b/jjb/lf-ci-jobs.yaml @@ -465,10 +465,10 @@ trigger-on: '{obj:gerrit_jjb_deploy_job_triggers}' projects: - project-compare-type: ANT - project-pattern: '{project}' + project-pattern: '**' branches: - branch-compare-type: ANT - branch-pattern: '**/{branch}' + branch-pattern: '**' skip-vote: success: true failed: true diff --git a/shell/jjb-deploy-job.sh b/shell/jjb-deploy-job.sh index 771f17b4..240c1faf 100644 --- a/shell/jjb-deploy-job.sh +++ b/shell/jjb-deploy-job.sh @@ -19,8 +19,11 @@ set -e -o pipefail # shellcheck source=/tmp/v/jenkins-job-builder/bin/activate disable=SC1091 source "/tmp/v/jenkins-job-builder/bin/activate" -echo "-----> Fetching project" -git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD +# Fetch patch if gerrit project matches the jjb-deploy project +if [ "${GERRIT_PROJECT}" == "${PROJECT}" ]; then + echo "-----> Fetching ${PROJECT} patch" + git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD +fi # If not Gerrit Trigger than assume GitHub COMMENT="${GERRIT_EVENT_COMMENT_TEXT:-$ghprbCommentBody}"