From 29503c4f91c32ba1c22324fe9318c3ed17054f77 Mon Sep 17 00:00:00 2001 From: mitesh51 Date: Sun, 3 Jun 2018 15:53:28 +0530 Subject: [PATCH] Changed --- Jenkinsfile | 56 +++++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e0f167bfb..f5feb93f3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,43 +1,35 @@ node { def mavenHome - - stage('Code Checkout') { - + + stage('Code Checkout') { // Get code from a repository and Git has to be installed in the system; git must be configured in the Global Tool Configuration git 'https://github.com/mitesh51/spring-petclinic.git' // Get the Maven tool configured in Global Tool Configuration // 'apache-maven-3.5.3' Maven tool must be configured in the global configuration. mavenHome = tool 'apache-maven-3.5.3' - } - stage('Code Analysis') { - - // Configure SonarQube Scanner in Manage Jenkins -> Global Tool Configuration - def scannerHome = tool 'SonarQube Scanner'; - - // Sonarqube 7 must be configured in the Jenkins Manage Jenkins -> Configure System -> Add SonarQube server - withSonarQubeEnv('Sonar7.1') { - - bat "${scannerHome}/bin/sonar-scanner - - Dsonar.host.url=http://localhost:9000 - - Dsonar.login=4589cdd82528c33f782b63254d9656d564f42bd1 - - Dsonar.projectVersion=1.0 - - Dsonar.projectKey=PetClinic_Key - - Dsonar.sources=src" - } - } - stage('Build') { - // Execute shell script if OS flavor is Linux - if (isUnix()) { - sh "'${mavenHome}/bin/mvn' -Dmaven.test.failure.ignore clean package" - // Publish JUnit Report - junit '**/target/surefire-reports/TEST-*.xml' - } - else { - // Execute Batch script if OS flavor is Windows - bat(/"${mavenHome}\bin\mvn" clean package/) - // Publish JUnit Report - junit '**/target/surefire-reports/TEST-*.xml' } + stage('Code Analysis') { + // Configure SonarQube Scanner in Manage Jenkins -> Global Tool Configuration + def scannerHome = tool 'SonarQube Scanner'; + + // Sonarqube 7 must be configured in the Jenkins Manage Jenkins -> Configure System -> Add SonarQube server + withSonarQubeEnv('Sonar7.1') { + bat "${scannerHome}/bin/sonar-scanner -Dsonar.host.url=http://localhost:9000 -Dsonar.login=4589cdd82528c33f782b63254d9656d564f42bd1 -Dsonar.projectVersion=1.0 -Dsonar.projectKey=PetClinic_Key -Dsonar.sources=src" + } + } + stage('Build') { + // Execute shell script if OS flavor is Linux + if (isUnix()) { + sh "'${mavenHome}/bin/mvn' -Dmaven.test.failure.ignore clean package" + // Publish JUnit Report + junit '**/target/surefire-reports/TEST-*.xml' + } + else { + // Execute Batch script if OS flavor is Windows + bat(/"${mavenHome}\bin\mvn" clean package/) + // Publish JUnit Report + junit '**/target/surefire-reports/TEST-*.xml' + } } }