1+ import hudson.model.*
2+
3+ pipeline {
4+
5+ agent any
6+
7+ options {
8+ timestamps()
9+ timeout(time : 1 , unit : " HOURS" )
10+ }
11+
12+ environment {
13+ TMPDIR = " target"
14+ ARTIFACTID = readMavenPom(). getArtifactId()
15+ GROUPID = readMavenPom(). getGroupId()
16+ VERSION = readMavenPom(). getVersion()
17+ BRANCH = " ${ GIT_BRANCH} " . replaceAll(" /" , " -" )
18+ MVN_OPTS = " --fail-at-end --threads 4"
19+ }
20+
21+ tools {
22+ maven " Maven 3.6.3"
23+ jdk " OpenJDK 11 (Latest)"
24+ }
25+
26+ stages {
27+ stage(" Initialize" ) {
28+ steps {
29+ chuckNorris()
30+ echo sh(returnStdout : true , script : " env" )
31+ notifyBitbucket0()
32+ }
33+ }
34+
35+ stage(" Build & Install" ) {
36+ steps {
37+ // sh "cat ~/.m2/settings.xml" // For checking the default settings to ensure my mvn-settings-di2e-jenkins.xml is set right for DI2E.
38+ sh " mvn clean jacoco:prepare-agent install jacoco:report ${ MVN_OPTS} "
39+ jacoco()
40+ }
41+ }
42+
43+ stage(" Scan" ) {
44+ steps {
45+ script {
46+ try {
47+ withSonarQubeDI2E()
48+ } catch (err) {
49+ echo " Error in sonarqube upload:"
50+ echo err. getMessage()
51+ }
52+ }
53+ }
54+ }
55+ }
56+ post {
57+ always {
58+ junit " **/target/surefire-reports/*.xml"
59+ archiveArtifacts artifacts : " **/target/*.jar" ,
60+ fingerprint : true
61+ notifyBitbucket0()
62+ }
63+ success {
64+ script {
65+ nexusArtifactUploader0()
66+ }
67+ }
68+ }
69+ }
70+
71+ def withSonarQubeDI2E () {
72+ withSonarQubeEnv(' Sonarqube Di2e Server' ) {
73+ script {
74+ def sonarScanner = tool name : ' SonarQube Scanner' , type : ' hudson.plugins.sonar.SonarRunnerInstallation'
75+ // Sonarqube token 8d28335e817bb96f7dc2a1b3f56dcf1d2c03bb6a
76+ sh " mvn sonar:sonar --activate-profiles sonarqube,site-reports -D sonar.branch.name=${ BRANCH} -D sonar.projectKey=RMBN-NETCONF-Java ${ MVN_OPTS} "
77+ }
78+ }
79+ }
80+
81+ def nexusArtifactUploader0 () {
82+ nexusArtifactUploader artifacts : [
83+ [artifactId : " ${ ARTIFACTID} " , file : " pom.xml" , type : " pom" ],
84+ [artifactId : " ${ ARTIFACTID} " , file : " target/${ ARTIFACTID} -${ VERSION} .jar" , type : " jar" ],
85+ [artifactId : " ${ ARTIFACTID} " , classifier : " sources" , file : " target/${ ARTIFACTID} -${ VERSION} -sources.jar" , type : " jar" ],
86+ [artifactId : " ${ ARTIFACTID} " , classifier : " javadoc" , file : " target/${ ARTIFACTID} -${ VERSION} -javadoc.jar" , type : " jar" ]
87+ ],
88+ credentialsId : " 687110ca-29bc-48c6-b35a-50b6040f1260" ,
89+ groupId : " ${ GROUPID} " ,
90+ nexusUrl : " nexus.di2e.net/nexus3" ,
91+ nexusVersion : " nexus3" ,
92+ protocol : " https" ,
93+ repository : " Public_DI2E_Maven" ,
94+ version : " ${ VERSION} "
95+ }
96+
97+ def notifyBitbucket0 () {
98+ notifyBitbucket commitSha1 : " ${ GIT_COMMIT} " ,
99+ considerUnstableAsSuccess : false ,
100+ credentialsId : " b901ff19-3484-442d-bc11-f6b3f2be7d26" ,
101+ disableInprogressNotification : false ,
102+ ignoreUnverifiedSSLPeer : false ,
103+ includeBuildNumberInKey : false ,
104+ prependParentProjectKey : false ,
105+ projectKey : " " ,
106+ stashServerBaseUrl : " https://bitbucket.di2e.net"
107+ }
0 commit comments