Skip to content

Commit 2b27ddf

Browse files
authored
Merge pull request #421 from karteekkanneganti/change_jenkins_build_to_jenkinsfile
change build to jenkinsfile and bump artifact version
2 parents f74b0fc + 64648bf commit 2b27ddf

File tree

12 files changed

+129
-15
lines changed

12 files changed

+129
-15
lines changed

Jenkinsfile

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
node ('build') {
2+
// Number of builds to keep
3+
properties ([
4+
buildDiscarder(logRotator(numToKeepStr: '10')),
5+
disableConcurrentBuilds()
6+
])
7+
8+
// Configure saxon home
9+
env.SAXON_HOME="/var/lib/jenkins/saxon_ee/"
10+
11+
// Configure GIT
12+
env.EMAIL="reposecore@rackspace.com"
13+
14+
def isPR = env.BRANCH_NAME.startsWith("PR-") // PRs start with PR-
15+
def isRelease = env.BRANCH_NAME.equals("master") // To Identify if its release
16+
17+
stage ("Pre Build") {
18+
// Clean the workspace before using it
19+
deleteDir()
20+
21+
// Print Environment and Java Version details
22+
sh 'printenv'
23+
sh 'java -version'
24+
25+
if (isRelease) {
26+
git url: 'https://github.com/rackerlabs/api-checker/',
27+
credentialsId: 'repose-bot',
28+
branch: env.BRANCH_NAME
29+
} else {
30+
// check out code, repo and branch are set by the actual job
31+
checkout scm
32+
}
33+
}
34+
35+
def skipBuild = sh (script: "git log -1 | grep '\\[maven-release-plugin\\]'", returnStatus: true)
36+
if (skipBuild == 0) {
37+
echo "Maven release detected"
38+
currentBuild.result = 'SUCCESS'
39+
return
40+
}
41+
42+
stage ("Build and Test") {
43+
// setting an environment block here limits these variables to anything in this stage
44+
environment {
45+
JENKINS_MAVEN_AGENT_DISABLED='true'
46+
}
47+
48+
try {
49+
// See https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Maven+Plugin
50+
// Run the maven build
51+
if (isRelease) {
52+
echo "Release build"
53+
def pom = readMavenPom file: 'pom.xml'
54+
def version = pom.version
55+
configFileProvider([configFile(fileId: 'api-checker-maven-artifactory-settings.xml', variable: 'MAVEN_SETTINGS')]) {
56+
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'repose-bot',
57+
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
58+
withMaven(maven: 'maven') {
59+
// Run tests first, then perform release, because of out of memory issues in jenkins.
60+
sh "mvn -B clean install"
61+
sh "mvn -B clean -P xerces-only install"
62+
sh """
63+
mvn clean -B -V -e -U -s $MAVEN_SETTINGS \
64+
-Dresume=false \
65+
-DdevelopmentVersion=${getNextDevVersion(version)} \
66+
-DreleaseVersion=${getReleaseVersion(version)} \
67+
-Dtag=${pom.artifactId}-${getReleaseVersion(version)} \
68+
-Dusername=${USERNAME} \
69+
-Dpassword=${PASSWORD} \
70+
-Darguments="-Dmaven.javadoc.skip=true" \
71+
release:prepare release:perform
72+
"""
73+
}
74+
}
75+
}
76+
} else {
77+
echo "Not a release"
78+
withMaven(maven: 'maven') {
79+
sh "mvn -B clean install"
80+
sh "mvn -B clean -P xerces-only install"
81+
}
82+
}
83+
} catch(e) {
84+
currentBuild.result = "FAILED"
85+
86+
// the withMaven plugin archives the surefire reports but not the failsafe or scalatest reports
87+
// on a failure, doing it manually here. TODO: fix failure reporting if needed
88+
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
89+
90+
throw e
91+
}
92+
}
93+
}
94+
95+
String getReleaseVersion(String version) {
96+
return version.replace("-SNAPSHOT", "")
97+
}
98+
99+
String getNextDevVersion(String version) {
100+
String currentRelease = getReleaseVersion(version)
101+
102+
String[] split = currentRelease.split("\\.")
103+
int nextMajor = split[1].toInteger() + 1
104+
105+
return "${split[0]}.${nextMajor}.0-SNAPSHOT"
106+
}

cli/checker-cli-parser/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.rackspace.papi.components.api-checker</groupId>
66
<artifactId>cli</artifactId>
7-
<version>2.8.1-SNAPSHOT</version>
7+
<version>2.9.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>com.rackspace.papi.components.api-checker.cli</groupId>
@@ -66,6 +66,7 @@
6666
<include>**/*.class</include>
6767
</includes>
6868
<enableAssertions>false</enableAssertions>
69+
<argLine>-Xms256m -Xmx1024m</argLine>
6970
</configuration>
7071
</plugin>
7172
</plugins>

cli/nailgun-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.rackspace.papi.components.api-checker</groupId>
66
<artifactId>cli</artifactId>
7-
<version>2.8.1-SNAPSHOT</version>
7+
<version>2.9.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>com.rackspace.papi.components.api-checker.cli</groupId>

cli/nailgun-server/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.rackspace.papi.components.api-checker</groupId>
66
<artifactId>cli</artifactId>
7-
<version>2.8.1-SNAPSHOT</version>
7+
<version>2.9.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>com.rackspace.papi.components.api-checker.cli</groupId>
@@ -116,6 +116,7 @@
116116
<include>**/*.class</include>
117117
</includes>
118118
<enableAssertions>false</enableAssertions>
119+
<argLine>-Xms256m -Xmx1024m</argLine>
119120
</configuration>
120121
</plugin>
121122
</plugins>

cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.rackspace.papi.components</groupId>
66
<artifactId>api-checker</artifactId>
7-
<version>2.8.1-SNAPSHOT</version>
7+
<version>2.9.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>com.rackspace.papi.components.api-checker</groupId>

cli/wadl2checker/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.rackspace.papi.components.api-checker</groupId>
66
<artifactId>cli</artifactId>
7-
<version>2.8.1-SNAPSHOT</version>
7+
<version>2.9.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>com.rackspace.papi.components.api-checker.cli</groupId>
@@ -111,6 +111,7 @@
111111
<include>**/*.class</include>
112112
</includes>
113113
<enableAssertions>false</enableAssertions>
114+
<argLine>-Xms256m -Xmx1024m</argLine>
114115
</configuration>
115116
</plugin>
116117
</plugins>

cli/wadl2dot/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.rackspace.papi.components.api-checker</groupId>
66
<artifactId>cli</artifactId>
7-
<version>2.8.1-SNAPSHOT</version>
7+
<version>2.9.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>com.rackspace.papi.components.api-checker.cli</groupId>
@@ -112,6 +112,7 @@
112112
<include>**/*.class</include>
113113
</includes>
114114
<enableAssertions>false</enableAssertions>
115+
<argLine>-Xms256m -Xmx1024m</argLine>
115116
</configuration>
116117
</plugin>
117118
</plugins>

cli/wadltest/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.rackspace.papi.components.api-checker</groupId>
66
<artifactId>cli</artifactId>
7-
<version>2.8.1-SNAPSHOT</version>
7+
<version>2.9.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>com.rackspace.papi.components.api-checker.cli</groupId>
@@ -120,6 +120,7 @@
120120
<include>**/*.class</include>
121121
</includes>
122122
<enableAssertions>false</enableAssertions>
123+
<argLine>-Xms256m -Xmx1024m</argLine>
123124
</configuration>
124125
</plugin>
125126
</plugins>

core/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.rackspace.papi.components</groupId>
66
<artifactId>api-checker</artifactId>
7-
<version>2.8.1-SNAPSHOT</version>
7+
<version>2.9.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>com.rackspace.papi.components.api-checker</groupId>
@@ -95,7 +95,7 @@
9595
<include>**/*.class</include>
9696
</includes>
9797
<enableAssertions>false</enableAssertions>
98-
<argLine>-Dfile.encoding=UTF-8</argLine>
98+
<argLine>-Dfile.encoding=UTF-8 -Xms256m -Xmx1024m</argLine>
9999
</configuration>
100100
</plugin>
101101
<plugin>
@@ -188,7 +188,7 @@
188188
<exclude>**/*SaxonEE.class</exclude>
189189
</excludes>
190190
<enableAssertions>false</enableAssertions>
191-
<argLine>-Dfile.encoding=UTF-8</argLine>
191+
<argLine>-Dfile.encoding=UTF-8 -Xms256m -Xmx1024m</argLine>
192192
</configuration>
193193
</plugin>
194194
</plugins>

macros/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.rackspace.papi.components</groupId>
66
<artifactId>api-checker</artifactId>
7-
<version>2.8.1-SNAPSHOT</version>
7+
<version>2.9.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>com.rackspace.papi.components.api-checker.macros</groupId>
@@ -80,7 +80,7 @@
8080
<include>**/*.class</include>
8181
</includes>
8282
<enableAssertions>false</enableAssertions>
83-
<argLine>-Dfile.encoding=UTF-8</argLine>
83+
<argLine>-Dfile.encoding=UTF-8 -Xms256m -Xmx1024m</argLine>
8484
</configuration>
8585
</plugin>
8686
</plugins>

pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.rackspace.papi.components</groupId>
44
<artifactId>api-checker</artifactId>
5-
<version>2.8.1-SNAPSHOT</version>
5+
<version>2.9.0-SNAPSHOT</version>
66
<packaging>pom</packaging>
77

88
<name>API Checker</name>
@@ -229,6 +229,9 @@
229229
<groupId>org.apache.maven.plugins</groupId>
230230
<artifactId>maven-release-plugin</artifactId>
231231
<version>2.5.3</version>
232+
<configuration>
233+
<arguments>-DskipTests</arguments>
234+
</configuration>
232235
<dependencies>
233236
<dependency>
234237
<groupId>org.apache.maven.scm</groupId>

util/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.rackspace.papi.components</groupId>
66
<artifactId>api-checker</artifactId>
7-
<version>2.8.1-SNAPSHOT</version>
7+
<version>2.9.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>com.rackspace.papi.components.api-checker</groupId>
@@ -77,7 +77,7 @@
7777
<include>**/*.class</include>
7878
</includes>
7979
<enableAssertions>false</enableAssertions>
80-
<argLine>-Dfile.encoding=UTF-8</argLine>
80+
<argLine>-Dfile.encoding=UTF-8 -Xms256m -Xmx1024m</argLine>
8181
</configuration>
8282
</plugin>
8383
</plugins>

0 commit comments

Comments
 (0)