mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 23:05:49 +00:00
Modified Jenkinsfile for testing.
This commit is contained in:
parent
6b0a0777f4
commit
c744a71a5f
1 changed files with 34 additions and 4 deletions
36
Jenkinsfile
vendored
36
Jenkinsfile
vendored
|
@ -13,25 +13,49 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Build') {
|
stage('Build Docker Image') {
|
||||||
steps {
|
steps {
|
||||||
sh './mvnw clean install'
|
script {
|
||||||
|
dockerImage = docker.build("spring-petclinic")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('SonarQube Analysis') {
|
stage('SonarQube Analysis') {
|
||||||
steps {
|
steps {
|
||||||
withSonarQubeEnv('SonarQube') {
|
withSonarQubeEnv('SonarQube') {
|
||||||
|
script {
|
||||||
|
dockerImage.inside("-u root") {
|
||||||
sh './mvnw sonar:sonar -Dsonar.projectKey=spring-petclinic'
|
sh './mvnw sonar:sonar -Dsonar.projectKey=spring-petclinic'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build Application') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
dockerImage.inside("-u root") {
|
||||||
|
sh './mvnw clean package -DskipTests'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Run Application') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
dockerImage.run("-p 8080:8080 --name spring-petclinic")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stage('OWASP ZAP') {
|
stage('OWASP ZAP') {
|
||||||
steps {
|
steps {
|
||||||
sh '''
|
sh '''
|
||||||
docker run --rm -v $(pwd)/zap-report:/zap/wrk:rw \
|
docker run --rm -v $(pwd)/zap-report:/zap/wrk:rw \
|
||||||
-t owasp/zap2docker-stable zap-baseline.py -t http://petclinic:8080 \
|
owasp/zap2docker-stable zap-baseline.py -t http://localhost:8080 \
|
||||||
-g gen.conf -r zap-report.html
|
-g gen.conf -r zap-report.html
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
@ -51,6 +75,12 @@ pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
|
always {
|
||||||
|
script {
|
||||||
|
dockerImage.stop()
|
||||||
|
dockerImage.remove()
|
||||||
|
}
|
||||||
|
}
|
||||||
success {
|
success {
|
||||||
echo 'Pipeline completed successfully!'
|
echo 'Pipeline completed successfully!'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue