forked from mozilla/bedrock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
64 lines (57 loc) · 2.07 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
#!groovy
@Library('github.com/mozmeao/[email protected]')
def loadBranch(String branch) {
// load the utility functions used below
utils = load 'jenkins/utils.groovy'
is_demo_branch = ( env.BRANCH_NAME ==~ /^demo\/[\w-]+$/ )
if ( fileExists("./jenkins/branches/${branch}.yml") ) {
config = readYaml file: "./jenkins/branches/${branch}.yml"
if ( !config.apps && is_demo_branch ) {
config.apps = [utils.demoAppName(env.BRANCH_NAME)]
}
println "config ==> ${config}"
} else if ( is_demo_branch ) {
config = readYaml file: "./jenkins/branches/demo/default.yml"
config.apps = [utils.demoAppName(env.BRANCH_NAME)]
println "config ==> ${config}"
} else {
println "No config for ${branch}. Nothing to do. Good bye."
return
}
if ( config.apps ) {
for ( app in config.apps ) {
if ( app.length() > 63 ) {
err_msg = "App name exceeds 63 char limit: ${app}"
utils.ircNotification([message: err_msg, status: 'failure'])
throw new Exception(err_msg)
}
}
}
// load the global config
global_config = readYaml file: 'jenkins/global.yml'
env.DEMO_MODE = config.demo ? 'true' : 'false'
// defined in the Library loaded above
setGitEnvironmentVariables()
setConfigEnvironmentVariables(global_config)
if ( config.pipeline && config.pipeline.script ) {
println "Loading ./jenkins/${config.pipeline.script}.groovy"
load "./jenkins/${config.pipeline.script}.groovy"
} else {
println "Loading ./jenkins/default.groovy"
load "./jenkins/default.groovy"
}
}
node {
stage ('Prepare') {
checkout scm
sh 'git submodule sync'
sh 'git submodule update --init --recursive'
// clean up
sh 'make clean'
// save the files for later
stash name: 'scripts', includes: 'bin/,docker/'
stash name: 'tests', includes: 'tests/,requirements/'
stash 'workspace'
}
loadBranch(env.BRANCH_NAME)
}