-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
77 lines (74 loc) · 1.57 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
66
67
68
69
70
71
72
73
74
75
76
pipeline {
agent {label 'general'}
parameters {
booleanParam(
name: 'ENABLE_BUILD',
defaultValue: true,
description: 'Build App'
)
string(
name: 'GIT_CREDENTIALS',
defaultValue: 'bitbucket',
description: 'git credentials'
)
string(
name: 'GIT_URL',
defaultValue: 'https://github.com/Ilhasoft/docker_kannel.git',
description: 'Git Repository URL'
)
string(
name: 'GIT_BRANCH',
defaultValue: 'master',
description: 'Git Repository BRANCH'
)
string(
name: 'DOCKER_IMAGE_NAME',
defaultValue: 'weniai/kannel',
description: 'Docker image name'
)
string(
name: 'DOCKER_IMAGE_TAG',
defaultValue: 'latest',
description: 'Docker image version to be used'
)
string(
name: 'DOCKER_REGISTRY_CREDENTIALS',
defaultValue: 'dockerhub_weni_admin',
description: 'Docker registry credentials'
)
string(
name: 'DOCKER_REGISTRY_URL',
defaultValue: '',
description: 'Docker registry urls'
)
}
stages{
stage('Build Image') {
when {
expression { params.ENABLE_BUILD }
}
steps {
script {
docker.build("${params.DOCKER_IMAGE_NAME}")
}
}
}
stage('Push Image') {
when {
expression { params.ENABLE_BUILD }
}
steps {
script {
def image=docker.build("${params.DOCKER_IMAGE_NAME}")
docker.withRegistry("${params.DOCKER_REGISTRY_URL}", "${params.DOCKER_REGISTRY_CREDENTIALS}") {
if( !BRANCH_NAME.startsWith("release-") ){
image.push("${params.DOCKER_IMAGE_TAG}")
}else{
image.push(BRANCH_NAME.minus('release-'))
}
}
}
}
}
}
}