-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfileOLD
executable file
·86 lines (80 loc) · 4.2 KB
/
JenkinsfileOLD
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
pipeline{
agent any
options {
buildDiscarder(logRotator(numToKeepStr:'20'))
}
parameters {
choice(choices: ['dev:mat:cqllibrary:search:tests:report','dev:mat:cql:library:report','dev:mat:cql:composer:report','dev:mat:measure:composer:report','dev:mat:measure:library:report','dev:all:mat:tests:report','dev:mat:smoke:tests:report','dev:mat:cqllibrary:grids:tests:report','test:all:mat:tests:report', 'dev:bonnieFHIR:measures:tests:report', 'dev:all:bonnieFHIR:tests:report', 'dev:all:bonnieQDM56:tests:report', 'dev:all:bonnieQDM55:tests:report', 'test:all:bonnieFHIR:tests:report', 'test:all:bonnieQDM56:tests:report'], description:'Choose the Test script to run', name: 'TEST_SCRIPT')
choice(name:'BUILD_CONTAINER', description:'Rebuild Cypress Container?', choices:['no','yes'])
}
environment{
AWS_ACCOUNT = credentials('HCQIS_NONPROD')
CYPRESS_DEV_USERNAME=credentials('CYPRESS_DEV_USERNAME')
CYPRESS_DEV_PASSWORD=credentials('CYPRESS_DEV_PASSWORD')
CYPRESS_DEV_ALT_USERNAME=credentials('CYPRESS_DEV_ALT_USERNAME')
CYPRESS_DEV_ALT_PASSWORD=credentials('CYPRESS_DEV_ALT_PASSWORD')
CYPRESS_TEST_USERNAME=credentials('CYPRESS_TEST_USERNAME')
CYPRESS_TEST_PASSWORD=credentials('CYPRESS_TEST_PASSWORD')
CYPRESS_TEST_ALT_USERNAME=credentials('CYPRESS_TEST_ALT_USERNAME')
CYPRESS_TEST_ALT_PASSWORD=credentials('CYPRESS_TEST_ALT_PASSWORD')
CYPRESS_VSAC_API_KEY=credentials('CYPRESS_VSAC_API_KEY')
CYPRESS_DEVQDM56_DB_MONGO_GROUPID=credentials('CYPRESS_DEVQDM56_DB_MONGO_GROUPID')
CYPRESS_DEVQDM55_DB_MONGO_GROUPID=credentials('CYPRESS_DEVQDM55_DB_MONGO_GROUPID')
CYPRESS_DEVFHIR_DB_MONGO_GROUPID=credentials('CYPRESS_DEVFHIR_DB_MONGO_GROUPID')
CYPRESS_TESTQDM56_DB_MONGO_GROUPID=credentials('CYPRESS_TESTQDM56_DB_MONGO_GROUPID')
CYPRESS_MONGO_URL=credentials('CYPRESS_MONGO_URL')
CYPRESS_MONGO_SSLCERT=credentials('CYPRESS_MONGO_SSLCERT')
CYPRESS_REPORT_BUCKET=credentials('CYPRESS_REPORT_BUCKET')
}
stages {
stage('ECR Login'){
steps{
sh 'aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${AWS_ACCOUNT}.dkr.ecr.us-east-1.amazonaws.com'
}
}
stage('Build Cypress Container'){
when{
expression { BUILD_CONTAINER == 'yes' }
}
steps{
sh '''
docker build -t mat-dev-cypress-ecr .
docker tag mat-dev-cypress-ecr:latest ${AWS_ACCOUNT}.dkr.ecr.us-east-1.amazonaws.com/mat-dev-cypress-ecr:latest
docker push ${AWS_ACCOUNT}.dkr.ecr.us-east-1.amazonaws.com/mat-dev-cypress-ecr:latest
'''
}
}
stage('Run Tests') {
agent {
docker {
image "${AWS_ACCOUNT}.dkr.ecr.us-east-1.amazonaws.com/mat-dev-cypress-ecr:latest"
args "-u 0 -v $HOME/.npm:/.npm"
reuseNode true
}
}
steps {
slackSend(color: "#ffff00", message: "#${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) - ${TEST_SCRIPT} Tests Started")
sh '''
cd /app/cypress
npm run ${TEST_SCRIPT}
aws s3 sync --acl public-read /app/mochawesome-report/ ${CYPRESS_REPORT_BUCKET}/mochawesome-report-${BUILD_NUMBER}/
echo "find reports at https://mat-reports.s3.amazonaws.com/mochawesome-report-${BUILD_NUMBER}/mochawesome.html"
tar -czf /app/mochawesome-report-${BUILD_NUMBER}.tar.gz -C /app/mochawesome-report/ .
cp /app/mochawesome-report-${BUILD_NUMBER}.tar.gz ${WORKSPACE}/
'''
}
}
}
post {
always{
archiveArtifacts artifacts: "mochawesome-report-${BUILD_NUMBER}.tar.gz"
}
success{
slackSend(color: "#00ff00", message: "${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) ${TEST_SCRIPT} Tests Finished, Review report at https://mat-reports.s3.amazonaws.com/mochawesome-report-${BUILD_NUMBER}/mochawesome.html")
}
failure{
sh 'echo fail'
slackSend(color: "#ff0000", message: "${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) ${TEST_SCRIPT} Tests Failed to Run or complete successfully")
}
}
}