Allow any project/branch to deploy jjb jobs
[releng/global-jjb.git] / shell / jjb-deploy-job.sh
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}"