jenkins: run tests when certain files change (#33682)

* test

* change

* work?

* debug

* git

* temp

* save

* test

* test

* work?

* fix

* test

* cleanup

* fix

* final test

* fix

* clean

* null

* final

* test

* save

* test this

* final
pull/33708/head^2
Maxime Desroches 8 months ago committed by GitHub
parent cf50d4ae19
commit eca88f5ea2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 32
      Jenkinsfile

32
Jenkinsfile vendored

@ -89,7 +89,12 @@ def deviceStage(String stageName, String deviceType, List extra_env, def steps)
device(device_ip, "git checkout", extra + "\n" + readFile("selfdrive/test/setup_device_ci.sh"))
}
steps.each { item ->
device(device_ip, item[0], item[1])
if (branch != "master" && item.size() == 3 && !hasPathChanged(item[2])) {
println "Skipping ${item[0]}: no changes in ${item[2]}."
return;
} else {
device(device_ip, item[0], item[1])
}
}
}
}
@ -97,6 +102,31 @@ def deviceStage(String stageName, String deviceType, List extra_env, def steps)
}
}
@NonCPS
def hasPathChanged(List<String> paths) {
changedFiles = []
for (changeLogSet in currentBuild.changeSets) {
for (entry in changeLogSet.getItems()) {
for (file in entry.getAffectedFiles()) {
changedFiles.add(file.getPath())
}
}
}
env.CHANGED_FILES = changedFiles.join(" ")
if (currentBuild.number > 1) {
env.CHANGED_FILES += currentBuild.previousBuild.getBuildVariables().get("CHANGED_FILES")
}
for (path in paths) {
if (env.CHANGED_FILES.contains(path)) {
return true;
}
}
return false;
}
def setupCredentials() {
withCredentials([
string(credentialsId: 'azure_token', variable: 'AZURE_TOKEN'),

Loading…
Cancel
Save