Skip to content

Instantly share code, notes, and snippets.

@lsjostro
Created April 20, 2016 08:33
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save lsjostro/3f410333ac90ecccfdc139079f585b3a to your computer and use it in GitHub Desktop.
Save lsjostro/3f410333ac90ecccfdc139079f585b3a 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
@StephenKing
Copy link

Noways, it's even possible without whitelisting access to the raw build, see https://support.cloudbees.com/hc/en-us/articles/217630098-How-to-access-Changelogs-in-a-Pipeline-Job-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment