diff --git a/Jenkinsfile b/Jenkinsfile index be7508be5..817200643 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,24 +1,18 @@ pipeline { - - agent any -/* - tools { - maven "maven3" - } -*/ + agent any + environment { NEXUS_VERSION = "nexus3" NEXUS_PROTOCOL = "http" NEXUS_URL = "172.31.40.209:8081" NEXUS_REPOSITORY = "vprofile-release" - NEXUS_REPO_ID = "vprofile-release" + NEXUS_REPO_ID = "vprofile-release" NEXUS_CREDENTIAL_ID = "nexuslogin" ARTVERSION = "${env.BUILD_ID}" } - - stages{ - - stage('BUILD'){ + + stages { + stage('BUILD') { steps { sh 'mvn clean install -DskipTests' } @@ -30,19 +24,19 @@ pipeline { } } - stage('UNIT TEST'){ + stage('UNIT TEST') { steps { sh 'mvn test' } } - stage('INTEGRATION TEST'){ + stage('INTEGRATION TEST') { steps { sh 'mvn verify -DskipUnitTests' } } - - stage ('CODE ANALYSIS WITH CHECKSTYLE'){ + + stage('CODE ANALYSIS WITH CHECKSTYLE') { steps { sh 'mvn checkstyle:checkstyle' } @@ -54,39 +48,39 @@ pipeline { } stage('CODE ANALYSIS with SONARQUBE') { - - environment { - scannerHome = tool 'sonarscanner4' - } - - steps { - withSonarQubeEnv('sonar-pro') { - sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ - -Dsonar.projectName=vprofile-repo \ - -Dsonar.projectVersion=1.0 \ - -Dsonar.sources=src/ \ - -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ - -Dsonar.junit.reportsPath=target/surefire-reports/ \ - -Dsonar.jacoco.reportsPath=target/jacoco.exec \ - -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' + environment { + scannerHome = tool 'sonarscanner4' } - timeout(time: 10, unit: 'MINUTES') { - waitForQualityGate abortPipeline: true + steps { + withSonarQubeEnv('sonar-pro') { + sh '''${scannerHome}/bin/sonar-scanner \ + -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=vprofile-repo \ + -Dsonar.projectVersion=1.0 \ + -Dsonar.sources=src/ \ + -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ + -Dsonar.junit.reportsPath=target/surefire-reports/ \ + -Dsonar.jacoco.reportsPath=target/jacoco.exec \ + -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' + } + + timeout(time: 10, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true + } } - } } stage("Publish to Nexus Repository Manager") { steps { script { - pom = readMavenPom file: "pom.xml"; - filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); + pom = readMavenPom file: "pom.xml" + filesByGlob = findFiles(glob: "target/*.${pom.packaging}") echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" - artifactPath = filesByGlob[0].path; - artifactExists = fileExists artifactPath; - if(artifactExists) { - echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version} ARTVERSION"; + artifactPath = filesByGlob[0].path + artifactExists = fileExists artifactPath + if (artifactExists) { + echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version} ARTVERSION" nexusArtifactUploader( nexusVersion: NEXUS_VERSION, protocol: NEXUS_PROTOCOL, @@ -96,26 +90,25 @@ pipeline { repository: NEXUS_REPOSITORY, credentialsId: NEXUS_CREDENTIAL_ID, artifacts: [ - [artifactId: pom.artifactId, - classifier: '', - file: artifactPath, - type: pom.packaging], - [artifactId: pom.artifactId, - classifier: '', - file: "pom.xml", - type: "pom"] + [ + artifactId: pom.artifactId, + classifier: '', + file: artifactPath, + type: pom.packaging + ], + [ + artifactId: pom.artifactId, + classifier: '', + file: "pom.xml", + type: "pom" + ] ] - ); - } - else { - error "*** File: ${artifactPath}, could not be found"; + ) + } else { + error "*** File: ${artifactPath}, could not be found" } } } } - - } - - }