forked from traum-ferienwohnungen/opsgenie-heartbeat-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
39 lines (36 loc) · 1.1 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
properties([
disableConcurrentBuilds()
])
node {
ws("workspace/$env.JOB_NAME/$env.BUILD_NUMBER".replace('%2F', '_')) {
def SCM_VARS
try {
stage('Checkout Source') {
SCM_VARS = checkout scm
}
stage('Publish Docker Image') {
registry = "949398260329.dkr.ecr.eu-west-1.amazonaws.com"
fullJobName = env.JOB_NAME.tokenize('/') as String[]
timestamp = new java.text.SimpleDateFormat("yyyyMMddHHmmss").format(new Date())
projectName = fullJobName[1]
version = "$timestamp-${SCM_VARS.GIT_COMMIT[0..7]}"
if (env.BRANCH_NAME == 'master') {
version = "release-$version"
} else {
version = "pr-${env.BRANCH_NAME.replaceAll('\\W', '_')}-$version"
}
currentBuild.displayName = version
dockerImageName = "$registry/$projectName:$version"
dockerImage = docker.build(dockerImageName, '.')
dockerImage.push()
if (env.BRANCH_NAME == 'master') {
dockerImage.push("latest")
}
}
} finally {
stage('Cleanup') {
deleteDir()
}
}
}
}