-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
45 lines (45 loc) · 1.14 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
pipeline {
environment {
registry = 'spiritreader/avior-nuxt'
registryCredentials = 'avior-nuxt-dh-login'
dockerImage = ''
defaultBranch = 'master'
}
agent {
label 'master'
}
stages {
stage('Build') {
steps {
script {
dockerImage = docker.build(registry + ":${GIT_LOCAL_BRANCH}-${BUILD_ID}",
"--build-arg=COMMIT=${GIT_COMMIT}"
+ ' .')
}
}
}
stage('Publish') {
steps {
script {
if (env.GIT_LOCAL_BRANCH == 'master') {
sh "echo 'prod environment, pushing to latest'"
docker.withRegistry('', registryCredentials) {
dockerImage.push('latest')
}
}
else {
sh "echo 'dev environment, pushing to $GIT_LOCAL_BRANCH-$BUILD_ID-'"
docker.withRegistry('', registryCredentials) {
dockerImage.push('${GIT_LOCAL_BRANCH}-${BUILD_ID}')
}
}
}
}
}
stage('CleanUp') {
steps {
sh "docker rmi $registry:$GIT_LOCAL_BRANCH-$BUILD_ID"
}
}
}
}