forked from Lukemufc91/NTDWorkshop2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
52 lines (52 loc) · 1.75 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
pipeline {
agent any
stages {
stage('Build API container') {
steps {
sh 'docker build . -t masterman/movie-api'
}
}
stage ('Run API container') {
steps {
sh ' docker run -p 3000:3000 --network bridge --name api-container --rm -d masterman/movie-api'
}
}
stage('Build Test container') {
steps {
sh 'docker build tests -t masterman/movie-api-tests'
}
}
stage('Execute tests') {
steps {
sh 'docker volume create test-reports'
sh 'docker run -e PORT=3000 -e BASE_URI=172.17.0.2 --network bridge -v test-reports:/usr/src/app --rm masterman/movie-api-tests'
}
}
stage('Retrieve reports') {
steps {
sh 'docker container create --name report-container -v test-reports:/root alpine'
sh 'docker cp report-container:/root/reports/. ${WORKSPACE}/reports'
}
}
stage('Cleanup') {
steps {
sh 'docker kill api-container'
sh 'docker rm report-container'
sh 'docker volume rm test-reports'
}
}
stage('Publish Test Results') {
steps {
junit skipPublishingChecks: true, testResults: 'reports/jest-junit.xml'
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'reports',
reportFiles: 'test-report.html',
reportName: 'Test Results'
]
}
}
}
}