2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 # Push a job to jenkins-sandbox via Gerrit / GitHub comment
12 # Comment Pattern: jjb-deploy JOB_NAME
13 # JOB_NAME: Can also include * wildcards too. Additional parameters are ignored.
14 echo "---> jjb-deploy-job.sh"
16 # Ensure we fail the job if any steps fail.
19 # shellcheck source=/tmp/v/jenkins-job-builder/bin/activate disable=SC1091
20 source "/tmp/v/jenkins-job-builder/bin/activate"
22 # Fetch patch if gerrit project matches the jjb-deploy project
23 if [ "${GERRIT_PROJECT}" == "${PROJECT}" ]; then
24 echo "-----> Fetching ${PROJECT} patch"
25 git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
28 # If not Gerrit Trigger than assume GitHub
29 COMMENT="${GERRIT_EVENT_COMMENT_TEXT:-$ghprbCommentBody}"
30 JOB_NAME=$(echo "$COMMENT" | grep jjb-deploy | awk '{print $2}')
32 # Strip all * characters to prevent pushing all jobs to Jenkins
33 if [ -z "${JOB_NAME//\*/}" ]; then
34 echo "ERROR: JOB_NAME cannot be empty or '*'."
38 jenkins-jobs update --jobs-only --recursive --workers 4 jjb/ "$JOB_NAME"