|
1 | 1 | #!/usr/bin/env groovy |
2 | 2 | @Library('pipeline-library')_ |
3 | 3 |
|
4 | | -def schedule = env.BRANCH_NAME.contains('master') ? '@monthly' : env.BRANCH_NAME == 'develop' ? '@midnight' : '' |
5 | | -def sonarBranchName = env.BRANCH_NAME.contains('master') ? '-Dsonar.branch.name=master' : '-Dsonar.branch.name=' + env.BRANCH_NAME |
6 | | -def sonarBranchTarget = env.BRANCH_NAME.contains('master') ? '' : env.BRANCH_NAME == 'develop' ? '-Dsonar.branch.target=master' : '-Dsonar.branch.target=develop' |
| 4 | +def repoName = "pdfSweep" |
| 5 | +def dependencyRegex = "itextcore" |
7 | 6 |
|
8 | | -pipeline { |
9 | | - |
10 | | - agent any |
11 | | - |
12 | | - environment { |
13 | | - JDK_VERSION = 'jdk-8-oracle' |
14 | | - } |
15 | | - |
16 | | - options { |
17 | | - ansiColor('xterm') |
18 | | - buildDiscarder(logRotator(artifactNumToKeepStr: '1')) |
19 | | - parallelsAlwaysFailFast() |
20 | | - skipStagesAfterUnstable() |
21 | | - timeout(time: 60, unit: 'MINUTES') |
22 | | - timestamps() |
23 | | - } |
24 | | - |
25 | | - triggers { |
26 | | - cron(schedule) |
27 | | - } |
28 | | - |
29 | | - tools { |
30 | | - maven 'M3' |
31 | | - jdk "${JDK_VERSION}" |
32 | | - } |
33 | | - |
34 | | - stages { |
35 | | - stage('Wait for blocking jobs') { |
36 | | - steps { |
37 | | - script { |
38 | | - properties([[$class: 'BuildBlockerProperty', blockLevel: 'GLOBAL', blockingJobs: ".*/itextcore/${env.JOB_BASE_NAME}", scanQueueFor: 'ALL', useBuildBlocker: true]]) |
39 | | - } |
40 | | - } |
41 | | - } |
42 | | - stage('Build') { |
43 | | - options { |
44 | | - retry(2) |
45 | | - } |
46 | | - stages { |
47 | | - stage('Clean workspace') { |
48 | | - options { |
49 | | - timeout(time: 5, unit: 'MINUTES') |
50 | | - } |
51 | | - steps { |
52 | | - withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') { |
53 | | - sh 'mvn clean' |
54 | | - sh 'mvn dependency:purge-local-repository -Dinclude=com.itextpdf -DresolutionFuzziness=groupId -DreResolve=false' |
55 | | - } |
56 | | - } |
57 | | - } |
58 | | - stage('Compile') { |
59 | | - options { |
60 | | - timeout(time: 5, unit: 'MINUTES') |
61 | | - } |
62 | | - steps { |
63 | | - withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') { |
64 | | - sh 'mvn compile test-compile package -Dmaven.test.skip=true -Dmaven.javadoc.failOnError=false' |
65 | | - } |
66 | | - } |
67 | | - } |
68 | | - } |
69 | | - post { |
70 | | - failure { |
71 | | - sleep time: 2, unit: 'MINUTES' |
72 | | - } |
73 | | - success { |
74 | | - script { currentBuild.result = 'SUCCESS' } |
75 | | - } |
76 | | - } |
77 | | - } |
78 | | - stage('Run Tests') { |
79 | | - options { |
80 | | - timeout(time: 30, unit: 'MINUTES') |
81 | | - } |
82 | | - steps { |
83 | | - withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') { |
84 | | - withSonarQubeEnv('Sonar') { |
85 | | - sh 'mvn --activate-profiles test -DgsExec="${gsExec}" -DcompareExec="${compareExec}" -Dmaven.test.skip=false -Dmaven.test.failure.ignore=false -Dmaven.javadoc.skip=true org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report -Dsonar.java.spotbugs.reportPaths="target/spotbugs.xml" sonar:sonar ' + sonarBranchName + ' ' + sonarBranchTarget |
86 | | - } |
87 | | - } |
88 | | - } |
89 | | - } |
90 | | - stage('Static Code Analysis') { |
91 | | - options { |
92 | | - timeout(time: 30, unit: 'MINUTES') |
93 | | - } |
94 | | - steps { |
95 | | - withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') { |
96 | | - sh 'mvn --activate-profiles qa verify -Dpmd.analysisCache=true' |
97 | | - } |
98 | | - } |
99 | | - } |
100 | | - stage("Quality Gate") { |
101 | | - steps { |
102 | | - timeout(time: 1, unit: 'HOURS') { |
103 | | - waitForQualityGate abortPipeline: true |
104 | | - } |
105 | | - } |
106 | | - } |
107 | | - stage('Artifactory Deploy') { |
108 | | - options { |
109 | | - timeout(time: 5, unit: 'MINUTES') |
110 | | - } |
111 | | - when { |
112 | | - anyOf { |
113 | | - branch "master" |
114 | | - branch "develop" |
115 | | - } |
116 | | - } |
117 | | - steps { |
118 | | - script { |
119 | | - def server = Artifactory.server('itext-artifactory') |
120 | | - def rtMaven = Artifactory.newMavenBuild() |
121 | | - rtMaven.deployer server: server, releaseRepo: 'releases', snapshotRepo: 'snapshot' |
122 | | - rtMaven.tool = 'M3' |
123 | | - def buildInfo = rtMaven.run pom: 'pom.xml', goals: 'install -Dmaven.test.skip=true -Dspotbugs.skip=true -Dmaven.javadoc.failOnError=false' |
124 | | - server.publishBuildInfo buildInfo |
125 | | - } |
126 | | - } |
127 | | - } |
128 | | - stage('Archive Artifacts') { |
129 | | - options { |
130 | | - timeout(time: 5, unit: 'MINUTES') |
131 | | - } |
132 | | - steps { |
133 | | - archiveArtifacts allowEmptyArchive: true, artifacts: 'target/*.jar, target/*.pom', excludes: '**/fb-contrib-*.jar, **/findsecbugs-plugin-*.jar' |
134 | | - } |
135 | | - } |
136 | | - } |
137 | | - |
138 | | - post { |
139 | | - always { |
140 | | - echo 'One way or another, I have finished \uD83E\uDD16' |
141 | | - } |
142 | | - success { |
143 | | - echo 'I succeeeded! \u263A' |
144 | | - } |
145 | | - unstable { |
146 | | - echo 'I am unstable \uD83D\uDE2E' |
147 | | - } |
148 | | - failure { |
149 | | - echo 'I failed \uD83D\uDCA9' |
150 | | - } |
151 | | - changed { |
152 | | - echo 'Things were different before... \uD83E\uDD14' |
153 | | - } |
154 | | - fixed { |
155 | | - script { |
156 | | - if (env.BRANCH_NAME.contains('master') || (env.BRANCH_NAME == 'develop')) { |
157 | | - slackNotifier("#ci", currentBuild.currentResult, "${env.BRANCH_NAME} - Back to normal") |
158 | | - } |
159 | | - } |
160 | | - } |
161 | | - regression { |
162 | | - script { |
163 | | - if (env.BRANCH_NAME.contains('master') || (env.BRANCH_NAME == 'develop')) { |
164 | | - slackNotifier("#ci", currentBuild.currentResult, "${env.BRANCH_NAME} - First failure") |
165 | | - } |
166 | | - } |
167 | | - } |
168 | | - } |
169 | | - |
170 | | -} |
| 7 | +automaticJavaBuild(repoName, dependencyRegex) |
0 commit comments