Fix: Pin setuptools in jjb-deploy-job.sh
[releng/global-jjb.git] / shell / jjb-deploy-job.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 #
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"
15
16 # Ensure we fail the job if any steps fail.
17 set -uef -o pipefail
18
19 # shellcheck disable=SC1090
20 source ~/lf-env.sh
21
22 # Version controlled by JJB_VERSION
23 lf-activate-venv --python python3 --venv-file /tmp/.jjb_venv jenkins-job-builder setuptools==65.7.0
24
25 # Fetch patch if gerrit project matches the jjb-deploy project
26 if [ "${GERRIT_PROJECT}" == "${PROJECT}" ]; then
27     echo "-----> Fetching ${PROJECT} patch"
28     git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
29 fi
30
31 # If not Gerrit Trigger than assume GitHub
32 COMMENT="${GERRIT_EVENT_COMMENT_TEXT:-$ghprbCommentBody}"
33 JOB_NAME=$(echo "$COMMENT" | grep jjb-deploy | awk '{print $2}')
34
35 # Strip all * characters to prevent pushing all jobs to Jenkins
36 if [ -z "${JOB_NAME//\*/}" ]; then
37     echo "ERROR: JOB_NAME cannot be empty or '*'."
38     exit 1
39 fi
40
41 echo "Deploying Job $JOB_NAME to sandbox"
42 jenkins-jobs -s sandbox update --jobs-only --recursive --workers 4 jjb/ "$JOB_NAME"