Skip to content

Commit 63d97d5

Browse files
committed
Add Jenkinsfile
Required for further automating deployment to Artifactory and apidocs. Also very useful for quick testing of upcoming change in QA-1118.
1 parent bf7ba45 commit 63d97d5

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

Jenkinsfile

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#!/usr/bin/env groovy
2+
3+
pipeline {
4+
5+
agent any
6+
7+
environment {
8+
JDK_VERSION = 'jdk-8-oracle'
9+
}
10+
11+
options {
12+
ansiColor('xterm')
13+
buildDiscarder(logRotator(artifactNumToKeepStr: '1'))
14+
parallelsAlwaysFailFast()
15+
retry(1)
16+
skipStagesAfterUnstable()
17+
timeout(time: 60, unit: 'MINUTES')
18+
timestamps()
19+
}
20+
21+
triggers {
22+
cron(env.BRANCH_NAME == 'develop' ? '@midnight' : '')
23+
}
24+
25+
tools {
26+
maven 'M3'
27+
jdk "${JDK_VERSION}"
28+
}
29+
30+
stages {
31+
stage('Clean workspace') {
32+
options {
33+
timeout(time: 5, unit: 'MINUTES')
34+
}
35+
steps {
36+
withMaven(jdk: "${JDK_VERSION}", maven: 'M3') {
37+
sh 'mvn clean'
38+
}
39+
}
40+
}
41+
stage('Compile') {
42+
options {
43+
timeout(time: 5, unit: 'MINUTES')
44+
}
45+
steps {
46+
withMaven(jdk: "${JDK_VERSION}", maven: 'M3') {
47+
sh 'mvn compile test-compile'
48+
}
49+
}
50+
}
51+
stage('Run Tests') {
52+
options {
53+
timeout(time: 30, unit: 'MINUTES')
54+
}
55+
environment {
56+
SONAR_BRANCH_TARGET= sh (returnStdout: true, script: '[ $BRANCH_NAME = master ] && echo master || echo develop').trim()
57+
}
58+
steps {
59+
withMaven(jdk: "${JDK_VERSION}", maven: 'M3') {
60+
withSonarQubeEnv('Sonar') {
61+
sh 'mvn --activate-profiles test verify -DgsExec="${gsExec}" -DcompareExec="${compareExec}" -Dmaven.test.skip=false -Dmaven.test.failure.ignore=false -Dmaven.javadoc.skip=true org.jacoco:jacoco-maven-plugin:prepare-agent org.jacoco:jacoco-maven-plugin:report sonar:sonar -Dsonar.branch.name="${BRANCH_NAME}" -Dsonar.branch.target="${SONAR_BRANCH_TARGET}"'
62+
}
63+
}
64+
}
65+
}
66+
stage('Static Code Analysis') {
67+
options {
68+
timeout(time: 30, unit: 'MINUTES')
69+
}
70+
steps {
71+
withMaven(jdk: "${JDK_VERSION}", maven: 'M3') {
72+
sh 'mvn --activate-profiles qa verify -Dpmd.analysisCache=true'
73+
}
74+
}
75+
}
76+
stage("Quality Gate") {
77+
steps {
78+
timeout(time: 1, unit: 'HOURS') {
79+
waitForQualityGate abortPipeline: true
80+
}
81+
}
82+
}
83+
stage('Artifactory Deploy') {
84+
options {
85+
timeout(time: 5, unit: 'MINUTES')
86+
}
87+
when {
88+
anyOf {
89+
branch "master"
90+
branch "develop"
91+
branch "7.0"
92+
branch "7.0-master"
93+
}
94+
}
95+
steps {
96+
script {
97+
def server = Artifactory.server('itext-artifactory')
98+
def rtMaven = Artifactory.newMavenBuild()
99+
rtMaven.deployer server: server, releaseRepo: 'releases', snapshotRepo: 'snapshot'
100+
rtMaven.tool = 'M3'
101+
def buildInfo = rtMaven.run pom: 'pom.xml', goals: 'install -Dmaven.test.skip=true -Dspotbugs.skip=true -Dmaven.javadoc.failOnError=false'
102+
server.publishBuildInfo buildInfo
103+
}
104+
}
105+
}
106+
stage('Archive Artifacts') {
107+
options {
108+
timeout(time: 5, unit: 'MINUTES')
109+
}
110+
steps {
111+
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.jar'
112+
}
113+
}
114+
}
115+
116+
post {
117+
always {
118+
echo 'One way or another, I have finished \uD83E\uDD16'
119+
}
120+
success {
121+
echo 'I succeeeded! \u263A'
122+
}
123+
unstable {
124+
echo 'I am unstable \uD83D\uDE2E'
125+
}
126+
failure {
127+
echo 'I failed \uD83D\uDCA9'
128+
}
129+
changed {
130+
echo 'Things were different before... \uD83E\uDD14'
131+
}
132+
}
133+
134+
}

0 commit comments

Comments
 (0)