-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
65 lines (65 loc) · 1.8 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
pipeline {
agent any
environment {
GIT_BRANCH = "${BRANCH_NAME}"
}
stages {
stage('install-dependencies') {
steps {
sh 'sudo docker container run -v "$(pwd):/app" --rm composer:1.6.3 install'
sh 'sudo docker container run -v "$(pwd):/app" --rm composer:1.6.3 dump-autoload'
}
}
stage('build-image') {
steps {
sh 'sudo docker build . -t wip-api'
sh 'sudo docker tag wip-api registry.wip.camp/wip-api'
sh 'sudo docker tag wip-api registry.wip.camp/wip-api:$GIT_BRANCH'
}
}
stage('push-image') {
steps {
sh 'sudo docker push registry.wip.camp/wip-api:$GIT_BRANCH'
sh 'sudo docker push registry.wip.camp/wip-api'
}
}
stage('versioning') {
when {
expression {
return GIT_BRANCH == 'master'
}
}
steps {
sh 'sudo docker tag wip-api registry.wip.camp/wip-api:$GIT_BRANCH-$BUILD_NUMBER'
sh 'sudo docker push registry.wip.camp/wip-api:$GIT_BRANCH-$BUILD_NUMBER'
sh 'sudo docker image rm registry.wip.camp/wip-api:$GIT_BRANCH-$BUILD_NUMBER'
}
}
stage('clean') {
steps {
sh 'sudo docker image rm registry.wip.camp/wip-api:$GIT_BRANCH'
sh 'sudo docker image rm registry.wip.camp/wip-api'
sh 'sudo docker image rm wip-api'
}
}
stage('deploy-development') {
when {
expression {
branch = sh(returnStdout: true, script: 'echo $GIT_BRANCH').trim()
return branch == 'develop'
}
}
steps {
sh 'sudo kubectl rolling-update wip-api -n development --image registry.wip.camp/wip-api:$GIT_BRANCH --image-pull-policy=Always'
}
}
}
post {
success {
sh 'echo success'
}
failure {
sh 'echo failure'
}
}
}