echo "---> jjb-deploy-job.sh"
# Ensure we fail the job if any steps fail.
-set -e -o pipefail
+set -uef -o pipefail
-# shellcheck source=/tmp/v/jenkins-job-builder/bin/activate disable=SC1091
-source "/tmp/v/jenkins-job-builder/bin/activate"
+# shellcheck disable=SC1090
+source ~/lf-env.sh
-echo "-----> Fetching project"
-git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
+# Version controlled by JJB_VERSION
+lf-activate-venv jenkins-job-builder
+
+# 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}"
exit 1
fi
-jenkins-jobs update --jobs-only --recursive --workers 4 jjb/ "$JOB_NAME"
+echo "Deploying Job $JOB_NAME to sandbox"
+jenkins-jobs -s sandbox update --jobs-only --recursive --workers 4 jjb/ "$JOB_NAME"