1
- podTemplate(label : ' build-pod-sourcerer-app' ,
1
+ // Copyright 2017 Sourcerer, Inc. All Rights Reserved.
2
+ // Author: Maxim Rusak ([email protected] )
3
+
4
+ def label = " sourcerer-app-${ UUID.randomUUID().toString()} "
5
+
6
+ def namespace = ' sandbox'
7
+ if (env. BRANCH_NAME == ' master' ) {
8
+ namespace = ' production'
9
+ } else if (env. BRANCH_NAME == ' develop' ) {
10
+ namespace = ' staging'
11
+ }
12
+
13
+ podTemplate(label : label,
2
14
containers : [
3
15
containerTemplate(name : ' jnlp' , image : ' gcr.io/sourcerer-1377/jenkins-slave:v4' , args : ' ${computer.jnlpmac} ${computer.name}' ),
4
16
containerTemplate(name : ' gradle' , image : ' gcr.io/sourcerer-1377/gradle:4.2.0' , ttyEnabled : true , command : ' tail -f /dev/null' )
5
17
],
6
18
envVars : [
7
- envVar(key : ' CONTAINER_TAG' , value : " ${ env.BRANCH_NAME} .${ env.BUILD_NUMBER} " )
19
+ envVar(key : ' NAMESPACE' , value : namespace),
20
+ envVar(key : ' CONTAINER_TAG' , value : " ${ namespace} .${ env.BUILD_NUMBER} .${ System.currentTimeMillis()} " )
8
21
],
9
22
volumes : [
10
23
hostPathVolume(hostPath : ' /var/run/docker.sock' , mountPath : ' /var/run/docker.sock' ),
11
24
hostPathVolume(hostPath : ' /usr/bin/docker' , mountPath : ' /usr/bin/docker' )
12
25
]
13
26
) {
14
- node(' build-pod-sourcerer-app' ) {
15
- def namespace = ' sandbox'
16
- def plog = ' debug'
17
-
18
- if (env. BRANCH_NAME == ' master' ) {
19
- namespace = ' production'
20
- plog = ' info'
21
- } else if (env. BRANCH_NAME == ' develop' ) {
22
- namespace = ' staging'
23
- plog = ' info'
24
- }
25
-
27
+ node(label) {
26
28
stage(' checkout' ) {
27
29
checkout scm
28
30
}
29
31
30
32
stage(' build jar and test' ) {
31
33
container(' gradle' ) {
32
- sh(" LOG= ${ plog } NAMESPACE= ${ namespace } ./do.sh build_jar_inside" )
34
+ sh(" ./do.sh build_jar_inside" )
33
35
}
34
36
}
35
37
@@ -45,7 +47,7 @@ podTemplate(label: 'build-pod-sourcerer-app',
45
47
46
48
stage(' deploy' ) {
47
49
println " Deploying to ${ namespace} kubernetes namespace"
48
- sh(" NAMESPACE= ${ namespace } ./do.sh deploy" )
50
+ sh(" ./do.sh deploy" )
49
51
}
50
52
}
51
53
}
0 commit comments