Skip to content

Instantly share code, notes, and snippets.

@yasinai
Forked from lsjostro/changesets.groovy
Created March 7, 2018 08:32
Show Gist options
  • Save yasinai/1d8a72e011a51d73fa0e3192dca4b1f4 to your computer and use it in GitHub Desktop.
Save yasinai/1d8a72e011a51d73fa0e3192dca4b1f4 to your computer and use it in GitHub Desktop.
Jenkinsfile: build only changed files
#!groovy
@NonCPS
def getACIChangeSets() {
def aci = []
currentBuild.rawBuild.getChangeSets().each { cs ->
cs.getItems().each { item ->
item.getAffectedFiles().each { f ->
if (f.path.endsWith(".yml")) {
aci << f.path
}
}
}
}
return aci
}
def acis = [:]
def aci = { f ->
def file_name = f
acis[f] = {
node ('my-builder'){
checkout scm
sh "aci_build ${file_name}"
}
}
}
def c = getACIChangeSets()
for (i = 0; i < c.size(); i++) {
aci c.get(i)
}
stage name: "Build ACI", concurrency: 8
parallel acis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment