Skip to content
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

jenkinsfile: filter stages based on path #612

Closed
wants to merge 1 commit into from
Closed
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
64 changes: 62 additions & 2 deletions apps/connector/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env groovy
library '[email protected]'

def changesDetected = false

pipeline {
agent { label 'linux' }

Expand All @@ -27,7 +29,41 @@ pipeline {
}

stages {
stage('Initial changelog checkout') {
when {
expression { currentBuild.previousCompletedBuild == null }
}
steps {
script {
checkout scmGit(
branches: scm.branches,
extensions: [
cloneOption(depth: 100, noTags: true, reference: '', shallow: true),
changelogToBranch(changelogBase(
compareRemote: 'origin',
compareTarget: CHANGE_TARGET
))
],
userRemoteConfigs: scm.userRemoteConfigs
)
}
}
}

stage('Check changes') {
when {
changeset pattern: "apps/connector/**", comparator: "GLOB"
}
steps {
script {
changesDetected = true
}
}
}
stage('Install') {
when {
expression { changesDetected }
}
steps {
dir("${env.WORKSPACE}/apps/connector") {
script {
Expand All @@ -42,6 +78,9 @@ pipeline {
}

stage('Build') {
when {
expression { changesDetected }
}
steps {
dir("${env.WORKSPACE}/apps/connector") {
script {
Expand All @@ -56,6 +95,9 @@ pipeline {
}

stage('Zip') {
when {
expression { changesDetected }
}
steps {
dir("${env.WORKSPACE}/apps/connector") {
zip(
Expand All @@ -68,6 +110,9 @@ pipeline {
}

stage('Archive') {
when {
expression { changesDetected }
}
steps {
dir("${env.WORKSPACE}/apps/connector") {
archiveArtifacts(
Expand All @@ -79,6 +124,9 @@ pipeline {
}

stage('Upload') {
when {
expression { changesDetected }
}
steps {
dir("${env.WORKSPACE}/apps/connector") {
script {
Expand All @@ -90,8 +138,20 @@ pipeline {
}

post {
success { script { github.notifyPR(true) } }
failure { script { github.notifyPR(false) } }
success {
script {
if(changesDetected) {
github.notifyPR(true)
}
}
}
failure {
script {
if(changesDetected) {
github.notifyPR(false)
}
}
}
cleanup { cleanWs() }
}
}
Loading