Allow any project/branch to deploy jjb jobs 64/10964/2
authorLuis Gomez <ecelgp@gmail.com>
Mon, 4 Jun 2018 16:20:34 +0000 (09:20 -0700)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 4 Jun 2018 17:03:05 +0000 (13:03 -0400)
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 <ecelgp@gmail.com>
jjb/lf-ci-jobs.yaml
shell/jjb-deploy-job.sh

index 24f6b69..668342a 100644 (file)
           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
index 771f17b..240c1fa 100644 (file)
@@ -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}"