-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
42 lines (42 loc) · 1.17 KB
/
Jenkinsfile
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
pipeline {
agent any
environment {
ZTL_API_TOKEN = credentials('zentral-api-token')
ZTL_FQDN = "zentral.example.com"
ZTL_MAIN_CONFIG = "Default"
ZTL_STAG_CONFIG = "Testing"
}
options {
disableConcurrentBuilds()
}
stages {
stage("Check rulesets") {
when { anyOf { changeRequest target: 'main'; changeRequest target: 'staging' } }
steps {
sh '''
if [ "$CHANGE_TARGET" = "main" ]; then
ZTL_CONFIG=$ZTL_MAIN_CONFIG
else
ZTL_CONFIG=$ZTL_STAG_CONFIG
fi
echo "*** Check the rulesets against the $ZTL_CONFIG configuration"
python3 scripts/post_rulesets.py rulesets "$ZTL_FQDN" "$ZTL_CONFIG" --dry-run
'''
}
}
stage("Apply rulesets") {
when { anyOf { branch 'main'; branch 'staging' } }
steps {
sh '''
if [ "$BRANCH_NAME" = "main" ]; then
ZTL_CONFIG=$ZTL_MAIN_CONFIG
else
ZTL_CONFIG=$ZTL_STAG_CONFIG
fi
echo "*** Apply the rulesets to the $ZTL_CONFIG configuration"
python3 scripts/post_rulesets.py rulesets "$ZTL_FQDN" "$ZTL_CONFIG"
'''
}
}
}
}