forked from mozmeao/infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
43 lines (38 loc) · 1.06 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
#!groovy
@Library('github.com/mozmeao/jenkins-pipeline@20170607.1')
def loadBranch(String branch) {
if (fileExists("./jenkins/${branch}.yaml")) {
config = readYaml file: "./jenkins/${branch}.yaml"
println "config ==> ${config}"
}
else {
config = []
}
if (config && config.pipeline && config.pipeline.enabled == false) {
println "Pipeline disabled."
}
else {
if (config && config.pipeline && config.pipeline.script) {
println "Loading ./jenkins/${config.pipeline.script}.groovy"
load "./jenkins/${config.pipeline.script}.groovy"
}
else {
println "Loading ./jenkins/${branch}.groovy"
load "./jenkins/${branch}.groovy"
}
}
}
node {
stage("Prepare") {
checkout scm
setGitEnvironmentVariables()
// When checking in a file exists in another directory start with './' or
// prepare to fail.
if (fileExists("./jenkins/${env.BRANCH_NAME}.groovy") || fileExists("./jenkins/${env.BRANCH_NAME}.yaml")) {
loadBranch(env.BRANCH_NAME)
}
else {
loadBranch("default")
}
}
}