From 943c8c18a307061e3f6185789be82dc40a35d21c Mon Sep 17 00:00:00 2001 From: Ashutosh Apurva Date: Wed, 15 Nov 2023 10:24:36 +0530 Subject: [PATCH] feat: add static code analysis stage to jenkinsfile --- Jenkinsfile | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fc88dafd..09ea210b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,20 +10,17 @@ pipeline { echo "build app" sh 'mvn clean package' echo "Build is successful for ${env.BUILD_ID}" - } - post { - success { - archiveArtifacts artifacts: 'target/*.war', fingerprint: true - } - } + } } - stage('Test') { - steps { - sh 'mvn test' - echo "Test is successful for ${env.BUILD_ID}" - - } - } + stage('Static Code Analysis') { + environment { + SONAR_URL = "http://172.18.0.4:9000" + } + steps { + withCredentials([string(credentialsId: 'sonarqube', variable: 'SONAR_AUTH_TOKEN')]) { + sh 'cd java-maven-sonar-argocd-helm-k8s/spring-boot-app && mvn sonar:sonar -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.host.url=${SONAR_URL}' + } + } } }