forked from jenkins-infra/jenkins-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile_updatecli
49 lines (48 loc) · 1.69 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
def cronExpr = env.BRANCH_IS_PRIMARY ? 'H/30 * * * *' : ''
pipeline {
// `docker` and `updatecli` are required
agent { label 'linux-amd64-docker' }
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 30, unit: 'MINUTES')
disableConcurrentBuilds(abortPrevious: true)
}
triggers {
cron (cronExpr)
}
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') {
withCredentials([
usernamePassword(
credentialsId: 'github-app-updatecli-on-jenkins-infra',
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 'updatecli version'
sh 'updatecli diff --config ./updatecli/weekly.d --values ./updatecli/values.yaml'
}
}
}
} // stage
stage('Apply Configuration Update') {
when {
expression { env.BRANCH_IS_PRIMARY }
}
steps {
withCredentials([
usernamePassword(
credentialsId: 'github-app-updatecli-on-jenkins-infra',
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 'updatecli apply --config ./updatecli/weekly.d --values ./updatecli/values.yaml'
}
}
}
}
}