mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 15:25:49 +00:00
Create JenkinsFile
This commit is contained in:
parent
516722647a
commit
9844afec94
1 changed files with 57 additions and 0 deletions
57
JenkinsFile
Normal file
57
JenkinsFile
Normal file
|
@ -0,0 +1,57 @@
|
|||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
MAVEN_HOME = tool 'maven'
|
||||
DOCKER_REGISTRY = 'your-jfrog-url'
|
||||
DOCKER_IMAGE = 'spring-petclinic'
|
||||
JFROG_REPO = 'your-jfrog-repo'
|
||||
CHECKSTYLE_REPORT = 'checkstyle-result.xml'
|
||||
JACOCO_REPORT = 'target/site/jacoco/jacoco.xml'
|
||||
SONAR_URL = 'http://localhost:9091' // Adjust URL according to your SonarQube instance
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('SCM Clone') {
|
||||
steps {
|
||||
git branch: 'main', url: 'https://github.com/NimalDas/spring-petclinic.git'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Maven Build') {
|
||||
steps {
|
||||
sh "${MAVEN_HOME}/bin/mvn clean package"
|
||||
}
|
||||
}
|
||||
stage('Checkstyle') {
|
||||
steps {
|
||||
sh "${MAVEN_HOME}/bin/mvn checkstyle:checkstyle"
|
||||
junit allowEmptyResults: true, testResults: '**/${CHECKSTYLE_REPORT}'
|
||||
}
|
||||
}
|
||||
stage('Unit Tests & JaCoCo') {
|
||||
steps {
|
||||
sh "${MAVEN_HOME}/bin/mvn test jacoco:report"
|
||||
junit allowEmptyResults: true, testResults: '**/surefire-reports/*.xml'
|
||||
jacoco(execPattern: 'target/**/*.exec', classPattern: '**/target/classes', sourcePattern: '**/src/main/java')
|
||||
}
|
||||
}
|
||||
|
||||
stage('SonarQube Analysis') {
|
||||
steps {
|
||||
withCredentials([string(credentialsId: 'sonartoken', variable: 'SONAR_TOKEN')]) {
|
||||
withSonarQubeEnv('sonarqube') {
|
||||
sh "${MAVEN_HOME}/bin/mvn sonar:sonar -Dsonar.host.url=${SONAR_URL} -Dsonar.login=${SONAR_TOKEN}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Docker Build & Push') {
|
||||
steps {
|
||||
script {
|
||||
docker.build("${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${env.BUILD_NUMBER}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue