diff --git a/Jenkinsfile b/Jenkinsfile index e69de29bb..5d8f7b3e5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -0,0 +1,37 @@ +pipeline { + agent { label 'JDK_17' } + triggers { pollSCM ('* * * * *') } + parameters { + choice(name: 'MAVEN_GOAL', choices: ['package', 'install', 'clean'], description: 'Maven Goal') + } + stages { + stage('vcs') { + steps { + git url: 'https://github.com/khajadevopsmarch23/spring-petclinic.git', + branch: 'declarative' + } + } + + stage('package') { + tools { + jdk 'JDK_17' + } + sh "mvn ${params.MAVEN_GOAL}" + } + } + stage('sonar analysis') { + steps { + // performing sonarqube analysis with "withSonarQubeENV()" + withSonarQubeEnv('SONAR_CLOUD') { + sh 'mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=nan_sonarcube' + } + } + } + stage('post build') { + steps { + archiveArtifacts artifacts: '**/target/spring-petclinic-3.0.0-SNAPSHOT.jar', + onlyIfSuccessful: true + junit testResults: '**/surefire-reports/TEST-*.xml' + } + } + } \ No newline at end of file