From c24789efbd2d7830cf2f3f206f220f6b0c1d8f8f Mon Sep 17 00:00:00 2001 From: Aseerwadham Date: Thu, 16 Mar 2023 15:41:47 +0530 Subject: [PATCH] Added Sonar Environment --- Jenkinsfile | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8f9511ded..8881030b6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,13 @@ 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/Aseerwadham/spring-petclinic.git', + git url: 'https://github.com/khajadevopsmarch23/spring-petclinic.git', branch: 'main' } } @@ -13,7 +16,14 @@ pipeline { jdk 'JDK_17' } steps { - sh "./mvnw package" + sh "mvn ${params.MAVEN_GOAL}" + } + } + stage('sonar analysis') { + steps { + withSonarQubeEnv('SONAR_CLOUD') { + sh 'mvn clean package sonar:sonar -Dsonar.organization=springpetclinic143' + } } } stage('post build') { @@ -24,6 +34,4 @@ pipeline { } } } -} - - +}