-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile.jenkinsfile
45 lines (38 loc) · 1.21 KB
/
Jenkinsfile.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 {
agent any
stages {
stage('Set environment') {
steps {
script {
def environment = 'staging'
if (env.GIT_BRANCH != 'origin/master') {
environment = env.GIT_BRANCH.split("/")[1]
println("Environment: ${environment}");
}
env.ENVIRONMENT_NAME = environment
env.DOCKER_LABEL = environment;
if (env.ENVIRONMENT_NAME == 'staging') {
env.DOCKER_LABEL = 'latest'
}
else if (env.ENVIRONMENT_NAME == 'develop') {
env.DOCKER_LABEL = 'develop'
}
println("Docker Label: ${env.DOCKER_LABEL}");
}
}
}
stage('Docker Build') {
steps {
sh "docker build -t contentgroup/painmanager:${env.DOCKER_LABEL} ."
}
}
stage('Docker Push') {
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub-jpercival', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {
sh 'docker login -u $dockerHubUser -p $dockerHubPassword'
sh "docker push contentgroup/painmanager:${env.DOCKER_LABEL}"
}
}
}
}
}