Skip to content

change build to jenkinsfile and bump artifact version #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
node ('build') {
// Number of builds to keep
properties ([
buildDiscarder(logRotator(numToKeepStr: '10')),
disableConcurrentBuilds()
])

// Configure saxon home
env.SAXON_HOME="/var/lib/jenkins/saxon_ee/"

// Configure GIT
env.EMAIL="reposecore@rackspace.com"

def isPR = env.BRANCH_NAME.startsWith("PR-") // PRs start with PR-
def isRelease = env.BRANCH_NAME.equals("master") // To Identify if its release

stage ("Pre Build") {
// Clean the workspace before using it
deleteDir()

// Print Environment and Java Version details
sh 'printenv'
sh 'java -version'

if (isRelease) {
git url: 'https://github.com/rackerlabs/api-checker/',
credentialsId: 'repose-bot',
branch: env.BRANCH_NAME
} else {
// check out code, repo and branch are set by the actual job
checkout scm
}
}

def skipBuild = sh (script: "git log -1 | grep '\\[maven-release-plugin\\]'", returnStatus: true)
if (skipBuild == 0) {
echo "Maven release detected"
currentBuild.result = 'SUCCESS'
return
}

stage ("Build and Test") {
// setting an environment block here limits these variables to anything in this stage
environment {
JENKINS_MAVEN_AGENT_DISABLED='true'
}

try {
// See https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Maven+Plugin
// Run the maven build
if (isRelease) {
echo "Release build"
def pom = readMavenPom file: 'pom.xml'
def version = pom.version
configFileProvider([configFile(fileId: 'api-checker-maven-artifactory-settings.xml', variable: 'MAVEN_SETTINGS')]) {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'repose-bot',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
withMaven(maven: 'maven') {
// Run tests first, then perform release, because of out of memory issues in jenkins.
sh "mvn -B clean install"
sh "mvn -B clean -P xerces-only install"
sh """
mvn clean -B -V -e -U -s $MAVEN_SETTINGS \
-Dresume=false \
-DdevelopmentVersion=${getNextDevVersion(version)} \
-DreleaseVersion=${getReleaseVersion(version)} \
-Dtag=${pom.artifactId}-${getReleaseVersion(version)} \
-Dusername=${USERNAME} \
-Dpassword=${PASSWORD} \
-Darguments="-Dmaven.javadoc.skip=true" \
release:prepare release:perform
"""
}
}
}
} else {
echo "Not a release"
withMaven(maven: 'maven') {
sh "mvn -B clean install"
sh "mvn -B clean -P xerces-only install"
}
}
} catch(e) {
currentBuild.result = "FAILED"

// the withMaven plugin archives the surefire reports but not the failsafe or scalatest reports
// on a failure, doing it manually here. TODO: fix failure reporting if needed
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])

throw e
}
}
}

String getReleaseVersion(String version) {
return version.replace("-SNAPSHOT", "")
}

String getNextDevVersion(String version) {
String currentRelease = getReleaseVersion(version)

String[] split = currentRelease.split("\\.")
int nextMajor = split[1].toInteger() + 1

return "${split[0]}.${nextMajor}.0-SNAPSHOT"
}
3 changes: 2 additions & 1 deletion cli/checker-cli-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.rackspace.papi.components.api-checker</groupId>
<artifactId>cli</artifactId>
<version>2.8.1-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
</parent>

<groupId>com.rackspace.papi.components.api-checker.cli</groupId>
Expand Down Expand Up @@ -66,6 +66,7 @@
<include>**/*.class</include>
</includes>
<enableAssertions>false</enableAssertions>
<argLine>-Xms256m -Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
2 changes: 1 addition & 1 deletion cli/nailgun-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.rackspace.papi.components.api-checker</groupId>
<artifactId>cli</artifactId>
<version>2.8.1-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
</parent>

<groupId>com.rackspace.papi.components.api-checker.cli</groupId>
Expand Down
3 changes: 2 additions & 1 deletion cli/nailgun-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.rackspace.papi.components.api-checker</groupId>
<artifactId>cli</artifactId>
<version>2.8.1-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
</parent>

<groupId>com.rackspace.papi.components.api-checker.cli</groupId>
Expand Down Expand Up @@ -116,6 +116,7 @@
<include>**/*.class</include>
</includes>
<enableAssertions>false</enableAssertions>
<argLine>-Xms256m -Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
2 changes: 1 addition & 1 deletion cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.rackspace.papi.components</groupId>
<artifactId>api-checker</artifactId>
<version>2.8.1-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
</parent>

<groupId>com.rackspace.papi.components.api-checker</groupId>
Expand Down
3 changes: 2 additions & 1 deletion cli/wadl2checker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.rackspace.papi.components.api-checker</groupId>
<artifactId>cli</artifactId>
<version>2.8.1-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
</parent>

<groupId>com.rackspace.papi.components.api-checker.cli</groupId>
Expand Down Expand Up @@ -111,6 +111,7 @@
<include>**/*.class</include>
</includes>
<enableAssertions>false</enableAssertions>
<argLine>-Xms256m -Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
3 changes: 2 additions & 1 deletion cli/wadl2dot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.rackspace.papi.components.api-checker</groupId>
<artifactId>cli</artifactId>
<version>2.8.1-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
</parent>

<groupId>com.rackspace.papi.components.api-checker.cli</groupId>
Expand Down Expand Up @@ -112,6 +112,7 @@
<include>**/*.class</include>
</includes>
<enableAssertions>false</enableAssertions>
<argLine>-Xms256m -Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
3 changes: 2 additions & 1 deletion cli/wadltest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.rackspace.papi.components.api-checker</groupId>
<artifactId>cli</artifactId>
<version>2.8.1-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
</parent>

<groupId>com.rackspace.papi.components.api-checker.cli</groupId>
Expand Down Expand Up @@ -120,6 +120,7 @@
<include>**/*.class</include>
</includes>
<enableAssertions>false</enableAssertions>
<argLine>-Xms256m -Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
6 changes: 3 additions & 3 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.rackspace.papi.components</groupId>
<artifactId>api-checker</artifactId>
<version>2.8.1-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
</parent>

<groupId>com.rackspace.papi.components.api-checker</groupId>
Expand Down Expand Up @@ -95,7 +95,7 @@
<include>**/*.class</include>
</includes>
<enableAssertions>false</enableAssertions>
<argLine>-Dfile.encoding=UTF-8</argLine>
<argLine>-Dfile.encoding=UTF-8 -Xms256m -Xmx1024m</argLine>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -188,7 +188,7 @@
<exclude>**/*SaxonEE.class</exclude>
</excludes>
<enableAssertions>false</enableAssertions>
<argLine>-Dfile.encoding=UTF-8</argLine>
<argLine>-Dfile.encoding=UTF-8 -Xms256m -Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
4 changes: 2 additions & 2 deletions macros/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.rackspace.papi.components</groupId>
<artifactId>api-checker</artifactId>
<version>2.8.1-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
</parent>

<groupId>com.rackspace.papi.components.api-checker.macros</groupId>
Expand Down Expand Up @@ -80,7 +80,7 @@
<include>**/*.class</include>
</includes>
<enableAssertions>false</enableAssertions>
<argLine>-Dfile.encoding=UTF-8</argLine>
<argLine>-Dfile.encoding=UTF-8 -Xms256m -Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.rackspace.papi.components</groupId>
<artifactId>api-checker</artifactId>
<version>2.8.1-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>API Checker</name>
Expand Down Expand Up @@ -229,6 +229,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<arguments>-DskipTests</arguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
Expand Down
4 changes: 2 additions & 2 deletions util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.rackspace.papi.components</groupId>
<artifactId>api-checker</artifactId>
<version>2.8.1-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
</parent>

<groupId>com.rackspace.papi.components.api-checker</groupId>
Expand Down Expand Up @@ -77,7 +77,7 @@
<include>**/*.class</include>
</includes>
<enableAssertions>false</enableAssertions>
<argLine>-Dfile.encoding=UTF-8</argLine>
<argLine>-Dfile.encoding=UTF-8 -Xms256m -Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
Expand Down