forked from chronic-care/mycareplanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.jenkinsfile
66 lines (56 loc) · 1.88 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
pipeline {
agent any
tools {nodejs "node11"}
stages {
stage('Set environment') {
steps {
script {
def environment = 'staging'
if (env.GIT_BRANCH != 'origin/master') {
environment = env.GIT_BRANCH.split("/")[1]
}
env.ENVIRONMENT_NAME = environment
println("Environment: ${env.ENVIRONMENT_NAME}");
env.DOCKER_LABEL = environment;
if (env.ENVIRONMENT_NAME == 'staging') {
env.CLOUDFRONT_DISTRIBUTION = 'E3MM1APWOMZXHB'
env.DOCKER_LABEL = 'latest'
}
else if (env.ENVIRONMENT_NAME == 'develop') {
env.CLOUDFRONT_DISTRIBUTION = 'E241WF4QIREH4O'
env.DOCKER_LABEL = 'develop'
}
println("CloudFront Distribution: ${env.CLOUDFRONT_DISTRIBUTION}");
println("Docker Label: ${env.DOCKER_LABEL}");
}
}
}
stage('Build') {
steps {
sh 'yarn install'
sh 'yarn build'
}
}
stage('Publish') {
steps {
withAWS(region:'us-west-2', credentials:'jasonevans') {
s3Upload(bucket: "cds4cpm-mypain-${env.ENVIRONMENT_NAME}", path: 'cds4cpm-mypain', workingDir: 'build', includePathPattern: '**/*')
cfInvalidate(distribution:"${env.CLOUDFRONT_DISTRIBUTION}", paths:['/*'], waitForCompletion: true)
}
}
}
stage('Docker Build') {
steps {
sh "docker build -t contentgroup/mypain:${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/mypain:${env.DOCKER_LABEL}"
}
}
}
}
}