-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
92 lines (83 loc) · 2.02 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
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
88
89
90
91
92
@Library(['gitops-pipeline-library@v4']) _
switch(env.BRANCH_NAME) {
case ~/PR-[0-9]+/:
testPipeline()
break
case 'development':
testPipeline()
buildPipeline()
deploymentPipeline(['gitops-qa'], true)
break
case 'master':
testPipeline()
buildPipeline()
deploymentPipeline(['gitops-staging'], false)
deploymentPipeline(['gitops-production'], false)
break
}
def pullModules() {
def moduleRepositories = [
'mod_push_skillz',
'mod_pottymouth',
'mod_beam_stats'
]
moduleRepositories.each { repo ->
git.cloneRepo(
destination: ".ejabberd_modules/sources/${repo}",
org: 'skillz',
repo: repo
)
}
}
def testPipeline() {
stage('Test') {
echo "TODO enable a way to run just the tests before building and deploying the image."
echo "Currently tests run as part of the docker build."
}
}
def buildPipeline() {
stage('Image') {
workerTemplates.github {
workerTemplates.docker {
node(POD_LABEL) {
def scmVars = checkout(scm)
def imageTag = scmVars.GIT_COMMIT
container('github') {
pullModules()
}
container('docker') {
dockerBuildPush(
tag: imageTag,
onlyArtifactory: true
)
}
}
}
}
}
}
def deploymentPipeline(List repos, boolean autoMerge = false) {
stage('GitOps Deploy') {
workerTemplates.github {
node(POD_LABEL) {
def scmVars = checkout(scm)
def imageTag = scmVars.GIT_COMMIT
container('github') {
def prBranch = "${repoName()}@${scmVars.GIT_BRANCH}"
def modifyFile = "apps/${repoName()}/release.yaml"
createPR(
branch: prBranch,
waitForStatus: false,
repos: repos,
autoMerge: autoMerge,
modifyYaml: [
file : modifyFile,
key : "imageTag",
desiredValue: imageTag
]
)
}
}
}
}
}