forked from mozilla/mozillians
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
71 lines (66 loc) · 2.33 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
node('master'){
def params
switch(env.BRANCH_NAME) {
case "master":
environment = "staging"
app_id_group = "/staging/"
break
case "production":
environment = "production"
app_id_group = ""
break
case "cistest":
environment = "cistest"
app_id_group = "/staging/"
break
default:
print "Invalid branch"
currentBuild.result = "FAILURE"
throw err
break
}
type = 'group'
slackSend channel: '#oi-parsys,#iam-bots', color: 'good', message: "Starting build ${BUILD_NUMBER} for ${JOB_NAME} ${environment} | <${BUILD_URL}changes | Changes>"
}
node('mesos') {
def image
def app_id = (environment == "cistest") ? "mozillianscistest" : "mozillians"
def dockerRegistry = "docker-registry.ops.mozilla.community:443"
stage('Prep') {
checkout scm
gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
params = [string(name: 'environment', value: "production"),
string(name: 'commit_id', value: gitCommit),
string(name: 'marathon_id', value: app_id_group + app_id),
string(name: 'marathon_config', value: 'mozillians_' + environment + '.json'),
string(name: 'type', value: 'group')]
}
stage('Build') {
try {
image = docker.build(app_id + ":" + gitCommit, "-f docker/prod .")
}
catch(e) {
currentBuild.result = "FAILURE"
slackSend channel: '#oi-parsys,#iam-bots', color: 'bad', message: "Error building ${JOB_NAME} ${BUILD_NUMBER} | <${BUILD_URL}console | Console>"
throw e
}
}
stage('Push') {
try {
sh "docker tag ${image.imageName()} " + dockerRegistry + "/${image.imageName()}"
sh "docker push " + dockerRegistry + "/${image.imageName()}"
}
catch(e) {
currentBuild.result = "FAILURE"
slackSend channel: '#oi-parsys,#iam-bots', color: 'bad', message: "Error pushing ${JOB_NAME} ${BUILD_NUMBER} | <${BUILD_URL}console | Console>"
throw e
}
}
}
node('master') {
stage('Deploy') {
parallel (
"deploy": { build job: 'deploy-test', parameters: params }
)
}
}