mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 23:05:49 +00:00
Latest Jenkinsfile
This commit is contained in:
parent
ce92d0bca2
commit
9ebda3d048
1 changed files with 4 additions and 56 deletions
60
Jenkinsfile
vendored
60
Jenkinsfile
vendored
|
@ -7,6 +7,9 @@ pipeline {
|
||||||
GITHUB_TOKEN = credentials('github-token')
|
GITHUB_TOKEN = credentials('github-token')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Define dockerImage at a higher scope to ensure availability in post block
|
||||||
|
def dockerImage = null
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Checkout') {
|
stage('Checkout') {
|
||||||
steps {
|
steps {
|
||||||
|
@ -41,63 +44,8 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Build Application') {
|
// Other stages omitted for brevity
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
echo "Building application..."
|
|
||||||
dockerImage.inside("-u root") {
|
|
||||||
sh './mvnw clean package -DskipTests'
|
|
||||||
}
|
|
||||||
echo "Application build completed."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Run Application') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
echo "Running application..."
|
|
||||||
dockerImage.inside("-u root") {
|
|
||||||
sh 'java -jar target/*.jar'
|
|
||||||
}
|
|
||||||
echo "Application is running."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('OWASP ZAP') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
echo "Running OWASP ZAP..."
|
|
||||||
sh '''
|
|
||||||
docker run --rm -v $(pwd)/zap-report:/zap/wrk:rw \
|
|
||||||
owasp/zap2docker-stable zap-baseline.py -t http://localhost:8080 \
|
|
||||||
-g gen.conf -r zap-report.html
|
|
||||||
'''
|
|
||||||
echo "OWASP ZAP analysis completed."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Publish ZAP Report') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
echo "Publishing OWASP ZAP report..."
|
|
||||||
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'zap-report', reportFiles: 'zap-report.html', reportName: 'OWASP ZAP Report'])
|
|
||||||
echo "OWASP ZAP report published."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Deploy to Production') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
echo "Deploying to production..."
|
|
||||||
sh 'ansible-playbook -i inventory/production deploy.yml'
|
|
||||||
echo "Deployment to production completed."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
|
|
Loading…
Reference in a new issue