Created
April 20, 2016 08:33
-
-
Save lsjostro/3f410333ac90ecccfdc139079f585b3a to your computer and use it in GitHub Desktop.
Jenkinsfile: build only changed files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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
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-