-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.jenkinsfile
107 lines (96 loc) · 3.89 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
pipeline {
agent any
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
env.DOCKER_LABEL = 'latest'
env.DOCKER_NAME = "cds4cpm_sandbox_${env.ENVIRONMENT_NAME}"
env.SANDBOX_HOST = "cds4cpm-${env.ENVIRONMENT_NAME}.sandbox"
if (environment == 'develop') {
env.BUCKET_NAME = "rti-ig-develop"
env.CLOUDFRONT_DISTRIBUTION_ID = "E264SBFRESXBSW"
env.DOCKER_LABEL = 'develop'
} else if (environment == 'staging') {
env.BUCKET_NAME = "rti-ig-staging"
env.CLOUDFRONT_DISTRIBUTION_ID = "E2RJE94LIGA2A6"
}
println("Environment: ${env.ENVIRONMENT_NAME}");
println("Docker Label: ${env.DOCKER_LABEL}");
println("Docker Name: ${env.DOCKER_NAME}");
println("Sandbox Host: ${env.SANDBOX_HOST}");
println("Bucket Name: ${env.BUCKET_NAME}")
println("Cloudfront ID: ${env.CLOUDFRONT_DISTRIBUTION_ID}")
}
}
}
stage('Deploy FHIR Sandbox') {
when {
expression { env.ENVIRONMENT_NAME == 'staging' || env.ENVIRONMENT_NAME == 'develop' }
}
steps {
script {
def remote = [:]
remote.name = "fhir.alphora.com"
remote.host = "fhir.alphora.com"
remote.allowAnyHosts = true
withCredentials([sshUserPrivateKey(credentialsId: '7d85c306-eb39-4445-ae15-bfeb99f34b33', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) {
remote.user = userName
remote.identityFile = identity
sshCommand remote: remote, command: "uptime; docker container stop ${env.DOCKER_NAME}; docker container rm ${env.DOCKER_NAME}; docker pull contentgroup/cqf-ruler:${env.DOCKER_LABEL}; docker run -d --name ${env.DOCKER_NAME} --label traefik.frontend.entryPoints=http,https --label traefik.frontend.rule=Host:${env.SANDBOX_HOST}.alphora.com -e SERVER_ADDRESS_DSTU3='https://${env.SANDBOX_HOST}.alphora.com/cqf-ruler-dstu3/fhir' -e SERVER_ADDRESS_R4='https://${env.SANDBOX_HOST}.alphora.com/cqf-ruler-r4/fhir' contentgroup/cqf-ruler:${env.DOCKER_LABEL}"
}
}
}
}
stage('Build IG') {
when {
expression { env.ENVIRONMENT_NAME == 'staging' || env.ENVIRONMENT_NAME == 'develop' }
}
steps {
sh './_build.sh'
}
}
stage('Publish IG') {
when {
expression { env.ENVIRONMENT_NAME == 'staging' || env.ENVIRONMENT_NAME == 'develop' }
}
steps {
withAWS(region:'us-west-2', credentials:'jasonevans') {
s3Upload(bucket: "${env.BUCKET_NAME}", workingDir: 'output', includePathPattern: '**/*')
cfInvalidate(distribution:"${env.CLOUDFRONT_DISTRIBUTION_ID}", paths:['/*'], waitForCompletion: true)
}
}
}
stage('Quiet Period') {
when {
expression { env.ENVIRONMENT_NAME == 'staging' || env.ENVIRONMENT_NAME == 'develop' }
}
steps {
sh 'sleep 1m'
}
}
stage('Publish CQF-Ruler Content') {
when {
expression { env.ENVIRONMENT_NAME == 'staging' || env.ENVIRONMENT_NAME == 'develop' }
}
steps {
script {
def BASE_R4_URL = "https://${env.SANDBOX_HOST}.alphora.com/cqf-ruler-r4/fhir"
def contentFolder = "${pwd()}/input/bundles"
println("Publishing content from ${contentFolder} to ${BASE_R4_URL}")
dir(contentFolder) {
def files = findFiles(glob: "**/*.json")
files.each { f ->
sh "curl -i -X POST -H 'Content-Type: application/json' -d @${f.path} ${BASE_R4_URL}"
}
}
}
}
}
}
}