Skip to content

Commit

Permalink
Merge pull request #1 from TonyMorrison/master
Browse files Browse the repository at this point in the history
BR-144 Create CI Pipeline for codice-itest
  • Loading branch information
dcruver authored Sep 17, 2020
2 parents 78d001e + ec5e339 commit d65e387
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 1 deletion.
117 changes: 117 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
@Library('github.com/connexta/cx-pipeline-library@master') _
@Library('github.com/connexta/github-utils-shared-library@master') __

pipeline {
agent {
node {
label 'linux-small'
customWorkspace "/jenkins/workspace/${JOB_NAME}/${BUILD_NUMBER}"
}
}
options {
buildDiscarder(logRotator(numToKeepStr:'25'))
disableConcurrentBuilds()
timestamps()
skipDefaultCheckout()
}
environment {
LARGE_MVN_OPTS = '-Xmx8192M -Xss128M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC '
LINUX_MVN_RANDOM = '-Djava.security.egd=file:/dev/./urandom'
GITHUB_USERNAME = 'codice'
GITHUB_TOKEN = credentials('github-api-cred')
GITHUB_REPONAME = 'codice-itest'
}
stages {
stage('Setup') {
steps {
dockerd {}
slackSend color: 'good', message: "STARTED: ${JOB_NAME} ${BUILD_NUMBER} ${BUILD_URL}"
postCommentIfPR("Internal build has been started, your results will be available at build completion.", "${GITHUB_USERNAME}", "${GITHUB_REPONAME}", "${GITHUB_TOKEN}")
}
}

// Checkout the repository
stage('Checkout repo') {
steps {
retry(3) {
checkout scm
}
}
}

// The incremental build will be triggered only for PRs. It will build the differences between the PR and the target branch
stage('Incremental Build') {
when {
allOf {
expression { env.CHANGE_ID != null }
expression { env.CHANGE_TARGET != null }
}
}
options {
timeout(time: 1, unit: 'HOURS')
}
steps {
withMaven(maven: 'maven-latest', globalMavenSettingsConfig: 'default-global-settings', mavenSettingsConfig: 'codice-maven-settings', mavenOpts: '${LARGE_MVN_OPTS} ${LINUX_MVN_RANDOM}') {
sh 'mvn install -B -DskipStatic=true -DskipTests=true'
sh 'mvn clean install -B -Dgib.enabled=true -Dgib.referenceBranch=/refs/remotes/origin/$CHANGE_TARGET'
}
}
}

stage('Full Build') {
when {
expression { env.CHANGE_ID == null }
}
options {
timeout(time: 1, unit: 'HOURS')
}
steps {
withMaven(maven: 'maven-latest', mavenSettingsConfig: 'codice-maven-settings', mavenOpts: '${LARGE_MVN_OPTS} ${LINUX_MVN_RANDOM}') {
sh 'mvn clean install'
}
}
}

/*
Deploy stage will only be executed for deployable branches.
It will also only deploy in the presence of an environment variable JENKINS_ENV = 'prod'. This can be passed in globally from the jenkins master node settings.
*/
stage('Deploy') {
when {
allOf {
expression { env.CHANGE_ID == null }
expression { env.BRANCH_NAME ==~ /((?:\d*\.)?\d*\.x|master)/ }
environment name: 'JENKINS_ENV', value: 'prod'
}
}
steps{
withMaven(maven: 'maven-latest', globalMavenSettingsConfig: 'default-global-settings', mavenSettingsConfig: 'codice-maven-settings', mavenOpts: '${LINUX_MVN_RANDOM}') {
sh 'mvn deploy -B -DskipStatic=true -DskipTests=true'
}
}
}
}
post {
always{
postCommentIfPR("Build ${currentBuild.currentResult} See the job results in [legacy Jenkins UI](${BUILD_URL}) or in [Blue Ocean UI](${BUILD_URL}display/redirect).", "${GITHUB_USERNAME}", "${GITHUB_REPONAME}", "${GITHUB_TOKEN}")
}
success {
slackSend color: 'good', message: "SUCCESS: ${JOB_NAME} ${BUILD_NUMBER}"
}
failure {
slackSend color: '#ea0017', message: "FAILURE: ${JOB_NAME} ${BUILD_NUMBER}. See the results here: ${BUILD_URL}"
}
unstable {
slackSend color: '#ffb600', message: "UNSTABLE: ${JOB_NAME} ${BUILD_NUMBER}. See the results here: ${BUILD_URL}"
}
cleanup {
catchError(buildResult: null, stageResult: 'FAILURE') {
echo '...Cleaning up workspace'
cleanWs()
wrap([$class: 'MesosSingleUseSlave']) {
sh 'echo "...Shutting down Jenkins slave: `hostname`"'
}
}
}
}
}
27 changes: 26 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ http://www.gnu.org/licenses/lgpl.html.

<groupId>org.codice</groupId>
<artifactId>codice-itest</artifactId>
<version>0.0.1</version>
<version>0.0.1-SNAPSHOT</version>

<properties>
<spring.version>5.2.8.RELEASE</spring.version>
Expand All @@ -26,9 +26,22 @@ http://www.gnu.org/licenses/lgpl.html.
<commons-lang3.version>3.11</commons-lang3.version>

<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven.release.plugin.version>3.0.0-M1</maven.release.plugin.version>

</properties>

<scm>
<url>https://github.com/codice/codice-itest</url>
<connection>scm:git:https://github.com/codice/codice-itest.git</connection>
<developerConnection>scm:git:https://github.com/codice/codice-itest.git</developerConnection>
<tag>HEAD</tag>
</scm>

<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<url>${snapshots.repository.url}</url>
</snapshotRepository>
<repository>
<id>releases</id>
<url>${releases.repository.url}</url>
Expand Down Expand Up @@ -138,6 +151,18 @@ http://www.gnu.org/licenses/lgpl.html.
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven.release.plugin.version}</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<preparationGoals>clean verify install</preparationGoals>
<pushChanges>false</pushChanges>
</configuration>
</plugin>

</plugins>
</build>
</project>

0 comments on commit d65e387

Please sign in to comment.