Skip to content

Commit

Permalink
Changed Jenkinsfile to support tag based releases.
Browse files Browse the repository at this point in the history
  • Loading branch information
jinnerbichler committed Dec 18, 2018
1 parent fa7f798 commit cb0f66e
Showing 1 changed file with 74 additions and 18 deletions.
92 changes: 74 additions & 18 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@

node('nimble-jenkins-slave') {

stage('Clone and Update') {
git(url: 'https://github.com/nimble-platform/data-channel-service.git', branch: env.BRANCH_NAME)
sh 'git submodule init'
sh 'git submodule update'
}
// -----------------------------------------------
// --------------- Staging Branch ----------------
// -----------------------------------------------
if (env.BRANCH_NAME == 'staging') {

stage('Build Dependencies') {
sh 'rm -rf common'
sh 'git clone https://github.com/nimble-platform/common'
dir('common') {
sh 'git checkout ' + env.BRANCH_NAME
sh 'mvn clean install'
stage('Clone and Update') {
git(url: 'https://github.com/nimble-platform/data-channel-service.git', branch: env.BRANCH_NAME)
sh 'git submodule init'
sh 'git submodule update'
}
}

stage('Build Java') {
sh 'mvn clean install -DskipTests'
}
stage('Build Dependencies') {
sh 'rm -rf common'
sh 'git clone https://github.com/nimble-platform/common'
dir('common') {
sh 'git checkout ' + env.BRANCH_NAME
sh 'mvn clean install'
}
}

stage('Build Java') {
sh 'mvn clean install -DskipTests'
}

if (env.BRANCH_NAME == 'staging') {
stage('Build Docker') {
sh 'mvn -f data-channel-service/pom.xml docker:build -DdockerImageTag=staging'
}
Expand All @@ -35,14 +39,66 @@ node('nimble-jenkins-slave') {
}
}

// -----------------------------------------------
// ---------------- Master Branch ----------------
// -----------------------------------------------
if (env.BRANCH_NAME == 'master') {

stage('Clone and Update') {
git(url: 'https://github.com/nimble-platform/data-channel-service.git', branch: env.BRANCH_NAME)
sh 'git submodule init'
sh 'git submodule update'
}

stage('Build Dependencies') {
sh 'rm -rf common'
sh 'git clone https://github.com/nimble-platform/common'
dir('common') {
sh 'git checkout ' + env.BRANCH_NAME
sh 'mvn clean install'
}
}

stage('Build Java') {
sh 'mvn clean install -DskipTests'
}
}

// -----------------------------------------------
// ---------------- Release Tags -----------------
// -----------------------------------------------
if( env.TAG_NAME ==~ /^\d+.\d+.\d+$/) {

stage('Clone and Update') {
git(url: 'https://github.com/nimble-platform/data-channel-service.git', branch: 'master')
sh 'git submodule init'
sh 'git submodule update'
}

stage('Build Dependencies') {
sh 'rm -rf common'
sh 'git clone https://github.com/nimble-platform/common'
dir('common') {
sh 'git checkout master'
sh 'mvn clean install'
}
}

stage('Set version') {
sh 'mvn versions:set -DnewVersion=' + env.TAG_NAME
sh 'mvn -f data-channel-service/pom.xml versions:set -DnewVersion=' + env.TAG_NAME
}

stage('Build Java') {
sh 'mvn clean install -DskipTests'
}

stage('Build Docker') {
sh 'mvn -f data-channel-service/pom.xml docker:build'
}

stage('Push Docker') {
sh 'mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version' // fetch dependencies
sh 'docker push nimbleplatform/data-channel-service:$(mvn -f data-channel-service/pom.xml org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v \'\\[\')'
sh 'docker push nimbleplatform/data-channel-service:' + env.TAG_NAME
sh 'docker push nimbleplatform/data-channel-service:latest'
}

Expand Down

0 comments on commit cb0f66e

Please sign in to comment.