From d1fb28b7eb1637042f6d9e56b53b1e6a25b3f8e8 Mon Sep 17 00:00:00 2001 From: Luis Gomez Date: Mon, 4 Jun 2018 09:20:34 -0700 Subject: [PATCH] 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 --- jjb/lf-ci-jobs.yaml | 4 ++-- shell/jjb-deploy-job.sh | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) 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}" -- 2.16.6