mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 07:15:49 +00:00
Update Jenkinsfile
This commit is contained in:
parent
27d3d9b3d5
commit
c23e5f6a2d
1 changed files with 14 additions and 15 deletions
27
Jenkinsfile
vendored
27
Jenkinsfile
vendored
|
@ -4,7 +4,6 @@ pipeline {
|
||||||
tools {
|
tools {
|
||||||
jdk 'jdk17'
|
jdk 'jdk17'
|
||||||
maven 'maven3'
|
maven 'maven3'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
|
@ -12,45 +11,45 @@ pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('compile ') {
|
stage('compile') {
|
||||||
steps {
|
steps {
|
||||||
sh 'mvn compile'
|
sh 'mvn compile'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('SonarQube Analysis') {
|
stage('SonarQube Analysis') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
// Run Maven with SonarQube plugin for analysis
|
// Run Maven with SonarQube plugin for analysis
|
||||||
withSonarQubeEnv('SonarQubeScanner') { // 'SonarQubeScanner' is the name of the SonarQube server configured in Jenkins
|
withSonarQubeEnv('SonarQubeScanner') {
|
||||||
sh """
|
sh """
|
||||||
mvn sonar:sonar -Dsonar.login=${SONAR_AUTH_TOKEN} \
|
mvn sonar:sonar -Dsonar.login=${SONAR_AUTH_TOKEN} \
|
||||||
-Dsonar.projectName=spring-petclinic \
|
-Dsonar.projectName=spring-petclinic \
|
||||||
-Dsonar.java.binaries=. \
|
-Dsonar.java.binaries=. \
|
||||||
-Dsonar.projectKey=spring-petclinic
|
-Dsonar.projectKey=spring-petclinic
|
||||||
"""
|
"""
|
||||||
//mvn sonar:sonar sonar maven plugin command
|
|
||||||
//Command: $SCANNER_HOME/bin/sonar-scanner standalone sonarqub scanner command
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("Quality Gate") {
|
stage("Quality Gate") {
|
||||||
steps {
|
steps {
|
||||||
timeout(time: 1, unit: 'HOURS') {
|
timeout(time: 1, unit: 'HOURS') {
|
||||||
script {
|
script {
|
||||||
def qg = waitForQualityGate()
|
def qg = waitForQualityGate()
|
||||||
if (qg.status != 'OK') {
|
if (qg.status != 'OK') {
|
||||||
error "Pipeline aborted due to quality gate failure: ${qg.status}"
|
error "Pipeline aborted due to quality gate failure: ${qg.status}"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Maven Package') {
|
stage('Maven Package') {
|
||||||
steps {
|
steps {
|
||||||
sh 'mvn clean package -DskipTests'
|
sh 'mvn clean package -DskipTests'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue