-
Notifications
You must be signed in to change notification settings - Fork 59
/
enable_jobs.sh
executable file
·85 lines (75 loc) · 1.87 KB
/
enable_jobs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
#
# Copyright (c) 2018-2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# script to enable jobs in Jenkins
# defaults
JENKINSURL="https://main-jenkins-csb-crwqe.apps.ocp-c1.prod.psi.redhat.com"
usage() {
echo "
Enable Jenkins jobs for a given release.
Usage: $0 [-t 2.y]
Example: $0 -t 2.y
"
exit
}
usageToken()
{
echo "To enable jobs, you must:
1. open ${JENKINSURL}/me/configure
2. create an API token
3. store your kerberos username and token in file /tmp/token, in format:
username:token
"
exit
}
# commandline args
while [[ "$#" -gt 0 ]]; do
case $1 in
'-t') DS_VERSION="$2"; shift 1;; # 2.y # version of job to delete from Jenkins
esac
shift 1
done
if [[ ! ${DS_VERSION} ]]; then usage; fi
if [[ -f /tmp/token ]]; then
USERTOKEN=$(cat /tmp/token)
for d in \
code\
configbump\
dashboard\
devfileregistry\
idea\
imagepuller\
machineexec\
operator-bundle\
operator\
pluginregistry\
server\
traefik\
dsc\
udi\
get-sources-rhpkg-container-build\
push-latest-container-to-quay\
sync-to-downstream\
update-digests\
Releng/job/build-all-images\
Releng/job/send-email-qe-build-list\
; do
result=$(curl -sSL -X POST "${JENKINSURL}/job/DS_CI/job/${d}_${DS_VERSION}/enable" --user "${USERTOKEN}" | grep -E "Unauthorized|Authentization|401|URI")
if [[ $result ]]; then
echo "ERROR!"
echo "$result"
echo
#usageToken
else
echo "Enabled: ${JENKINSURL}/job/DS_CI/job/${d}_${DS_VERSION}/"
fi
done
else
usageToken
fi