-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
64 lines (58 loc) · 2.02 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
pipeline {
agent any
// Scan will run everyday on master
triggers { cron( (BRANCH_NAME == "master") ? "@daily" : "" ) }
stages {
stage('Dependency check') {
steps {
sh "mvn --batch-mode dependency-check:check"
}
post {
always {
publishHTML(target:[
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'target',
reportFiles: 'dependency-check-report.html',
reportName: "OWASP Dependency Check Report"
])
}
}
}
stage('Build') {
steps {
echo 'Build'
sh "mvn --batch-mode package"
}
}
stage('Archive Unit Tests Results') {
steps {
echo 'Archive Unit Test Results'
step([$class: 'JUnitResultArchiver', testResults: 'target/surefire-reports/TEST-*.xml'])
}
}
stage('Publish Unit Test results report') {
steps {
echo 'Report'
publishHTML([allowMissing: false, alwaysLinkToLastBuild: true, keepAll: false, reportDir: 'target/site/jacoco/', reportFiles: 'index.html', reportName: 'jacaco report', reportTitles: ''])
}
}
stage('Deploy') {
steps {
echo 'Deploy'
sh '''
for runName in `docker ps | grep "alpine-petclinic" | awk '{print $1}'`
do
if [ "$runName" != "" ]
then
docker stop $runName
fi
done
docker build -t alpine-petclinic -f Dockerfile.deploy .
docker run --name alpine-petclinic --rm -d -p 9966:8080 alpine-petclinic
'''
}
}
}
}