-
Notifications
You must be signed in to change notification settings - Fork 279
/
Copy pathJenkinsfile
54 lines (46 loc) · 1.46 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
// Copyright 2017 Sourcerer, Inc. All Rights Reserved.
// Author: Maxim Rusak (maxim@sourcerer.io)
def label = "sourcerer-app-${UUID.randomUUID().toString()}"
def namespace = 'sandbox'
if (env.BRANCH_NAME == 'master') {
namespace = 'production'
} else if (env.BRANCH_NAME == 'develop') {
namespace = 'staging'
}
podTemplate(label: label,
containers: [
containerTemplate(name: 'jnlp', image: 'gcr.io/sourcerer-1377/jenkins-slave:v4', args: '${computer.jnlpmac} ${computer.name}'),
containerTemplate(name: 'gradle', image: 'gcr.io/sourcerer-1377/gradle:4.2.0', ttyEnabled: true, command: 'tail -f /dev/null')
],
envVars: [
envVar(key: 'NAMESPACE', value: namespace),
envVar(key: 'CONTAINER_TAG', value: "${namespace}.${env.BUILD_NUMBER}.${System.currentTimeMillis()}")
],
volumes: [
hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock'),
hostPathVolume(hostPath: '/usr/bin/docker', mountPath: '/usr/bin/docker')
]
) {
node(label) {
stage('checkout') {
checkout scm
}
stage('build jar and test') {
container('gradle') {
sh("./do.sh build_jar_inside")
}
}
stage('build nginx') {
container('gradle') {
sh("./do.sh build_prod_inside")
}
}
stage('push') {
sh("./do.sh push")
}
stage('deploy') {
println "Deploying to ${namespace} kubernetes namespace"
sh("./do.sh deploy")
}
}
}