-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate-ps.sh
executable file
·87 lines (73 loc) · 1.81 KB
/
create-ps.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
86
87
#!/bin/bash
# This script creates a new job definition in Zuul CI, then it makes
# a PatchSet in Gerrit to trigger the new job.
COMMAND=${COMMAND:-"sleep 300"}
SF_OPERATOR_DIR=$(readlink -f "$(pwd)")
GERRIT_ADMIN_API_KEY=$("${SF_OPERATOR_DIR}/hack/get-secret.sh" gerrit-admin-api-key)
TMP_DIR=$(mktemp -d)
if ! command -v pip3; then
echo "Please install pip package!"
exit 1
fi
if ! command -v git-review; then
python3 -mvenv .venv && .venv/bin/pip3 install git-review
VENV_PATH=$PATH:$(pwd)/.venv/bin
export PATH=$VENV_PATH
fi
git clone \
-c user.name="Admin" \
-c user.email="[email protected]" \
-c http.sslVerify=false \
"https://admin:${GERRIT_ADMIN_API_KEY}@gerrit.sfop.me/a/config" "$TMP_DIR/config"
cd "$TMP_DIR/config"
mkdir -p "$TMP_DIR/config/playbooks"
mkdir -p "$TMP_DIR/config/zuul.d"
git config user.name "Admin"
git config user.email [email protected]
git config http.sslVerify false
git remote add gerrit "https://admin:${GERRIT_ADMIN_API_KEY}@gerrit.sfop.me/a/config"
cat << EOF > zuul.d/config.yaml
---
- job:
name: test-job
run: playbooks/test.yml
cleanup-run:
name: playbooks/sleep.yml
nodeset:
nodes:
- name: container
label: zuul-worker-sf-operator-ci
- project:
check:
jobs:
- test-job
gate:
jobs:
- config-check
post:
jobs:
- config-update
EOF
cat << EOF > playbooks/test.yml
---
- hosts: localhost,all
tasks:
- name: Doing command
command: $COMMAND
EOF
cat << EOF > playbooks/sleep.yml
---
- hosts: localhost,all
tasks:
- name: Doing command
command: $COMMAND
EOF
git add .
git commit -m "Add check job"
git push origin master
echo "test" > test-file
git add test-file
git commit -m 'Executing test PS'
git-review
echo -e "\n\nTemp dir is: $TMP_DIR\n\n"
cd -