-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
69 lines (69 loc) · 2.08 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
pipeline {
parameters {
choice(name: 'app', choices: ['showcase', 'cardio-patient', 'cardio'], description: 'Select the app to build and deploy')
}
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '30'))
}
environment {
APP = "${params.app}"
AWS_CREDENTIALS = credentials('AWS-KEYS')
AWS_ENV = """${sh(
returnStdout: true,
script: 'env | awk -F= \'/^AWS/ {print "-e " $1}\''
)}"""
GIT_ENV = """${sh(
returnStdout: true,
script: 'env | awk -F= \'/^GIT/ {print "-e " $1}\''
)}"""
}
stages {
stage('Setup') {
steps {
sh '''
docker pull $CICD_ECR_REGISTRY/cicd:latest
docker tag $CICD_ECR_REGISTRY/cicd:latest cicd:latest
'''
}
}
stage('Build') {
steps {
echo 'Building Docker Image'
sh 'docker build --build-arg app=' + APP + ' -t ' + APP + '-web -f Dockerfile .'
}
}
stage('Push') {
steps {
echo 'Pushing Docker Image'
sh 'docker run -v /var/run/docker.sock:/var/run/docker.sock $AWS_ENV $GIT_ENV cicd push ' + APP + '-web'
}
}
stage('Deploy') {
steps {
echo 'Deploying to QA'
sh 'docker run -v /var/run/docker.sock:/var/run/docker.sock $AWS_ENV $GIT_ENV cicd deploy ' + APP + '-web qa $GIT_COMMIT'
}
}
stage('Wait') {
steps {
echo 'Waiting for QA service to reach steady state'
sh 'docker run -v /var/run/docker.sock:/var/run/docker.sock $AWS_ENV cicd wait ' + APP + '-web qa'
}
}
stage('Healthcheck') {
steps {
echo 'Checking health of QA service'
sh "curl -m 10 https://$APP-qa.elimuinformatics.com/"
}
}
}
post {
unsuccessful {
slackSend color: 'danger', channel: '#product-ops-qa', message: "Pipeline Failed For App: ${APP} ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
}
fixed {
slackSend color: 'good', channel: '#product-ops-qa', message: "Pipeline Ran Successfully For App: ${APP} ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
}
}
}