-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
47 lines (47 loc) · 1.83 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
pipeline {
agent { label 'docker' }
stages {
stage('Build') {
steps {
script {
props=readProperties file: 'gradle.properties'
}
sh "docker build --tag ${GIT_COMMIT} --build-arg apiVersion=${props.apiVersion} ."
}
}
stage('Publish') {
when {
branch 'master'
}
steps {
sh "docker tag ${GIT_COMMIT} fintlabsacr.azurecr.io/org-monitor:build.${BUILD_NUMBER}"
withDockerRegistry([credentialsId: 'fintlabsacr.azurecr.io', url: 'https://fintlabsacr.azurecr.io']) {
sh "docker push fintlabsacr.azurecr.io/org-monitor:build.${BUILD_NUMBER}"
}
}
}
stage('Publish PR') {
when { changeRequest() }
steps {
sh "docker tag ${GIT_COMMIT} fintlabsacr.azurecr.io/org-monitor:${BRANCH_NAME}.${BUILD_NUMBER}"
withDockerRegistry([credentialsId: 'fintlabsacr.azurecr.io', url: 'https://fintlabsacr.azurecr.io']) {
sh "docker push fintlabsacr.azurecr.io/org-monitor:${BRANCH_NAME}.${BUILD_NUMBER}"
}
}
}
stage('Publish Version') {
when {
tag pattern: "v\\d+\\.\\d+\\.\\d+(-\\w+-\\d+)?", comparator: "REGEXP"
}
steps {
script {
VERSION = TAG_NAME[1..-1]
}
sh "docker tag ${GIT_COMMIT} fintlabsacr.azurecr.io/org-monitor:${VERSION}"
withDockerRegistry([credentialsId: 'fintlabsacr.azurecr.io', url: 'https://fintlabsacr.azurecr.io']) {
sh "docker push fintlabsacr.azurecr.io/org-monitor:${VERSION}"
}
}
}
}
}