-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Jenkinsfile_updatecli
65 lines (61 loc) · 2.37 KB
/
Jenkinsfile_updatecli
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
def cronExpr = env.BRANCH_IS_PRIMARY ? 'H/30 * * * *' : ''
pipeline {
agent {
label 'jnlp-linux-arm64'
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 30, unit: 'MINUTES')
disableConcurrentBuilds()
}
triggers {
cron (cronExpr)
}
environment {
UPDATECLI_AZURE = credentials('updatecli-azure-serviceprincipal') //needed for az login
}
stages {
stage('Check Configuration Update') {
// Run updatecli's diff on both push and pull requests (in case a configuration change breaks updatecli)
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
script {
withCredentials([
usernamePassword(
credentialsId: 'github-app-updatecli-on-jenkins-infra', //needed for updatecli
usernameVariable: 'USERNAME_VALUE', // Setting this variable is mandatory, even if of not used when the credentials is a githubApp one
passwordVariable: 'UPDATECLI_GITHUB_TOKEN'
)
]) {
sh 'az login --service-principal -u "$UPDATECLI_AZURE_CLIENT_ID" -p "$UPDATECLI_AZURE_CLIENT_SECRET" -t "$UPDATECLI_AZURE_TENANT_ID"'
sh 'az account set -s "$UPDATECLI_AZURE_SUBSCRIPTION_ID"'
sh 'updatecli version'
sh 'updatecli diff --values ./updatecli/values.yaml --config ./updatecli/updatecli.d'
}
}
}
}
} // stage
stage('Apply Configuration Update') {
when {
expression { env.BRANCH_IS_PRIMARY }
}
steps {
script {
withCredentials([
usernamePassword(
credentialsId: 'github-app-updatecli-on-jenkins-infra', //needed for updatecli
usernameVariable: 'USERNAME_VALUE', // Setting this variable is mandatory, even if of not used when the credentials is a githubApp one
passwordVariable: 'UPDATECLI_GITHUB_TOKEN'
)
]) {
sh 'az login --service-principal -u "$UPDATECLI_AZURE_CLIENT_ID" -p "$UPDATECLI_AZURE_CLIENT_SECRET" -t "$UPDATECLI_AZURE_TENANT_ID"'
sh 'az account set -s "$UPDATECLI_AZURE_SUBSCRIPTION_ID"'
sh 'updatecli version'
sh 'updatecli apply --values ./updatecli/values.yaml --config ./updatecli/updatecli.d'
}
}
}
}
}
}