Skip to content

Commit

Permalink
jenkins: run tests when certain files change (#33682)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
maxime-desroches authored Oct 6, 2024
1 parent cf50d4a commit eca88f5
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,44 @@ 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])
}
}
}
}
}
}
}

@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'),
Expand Down

0 comments on commit eca88f5

Please sign in to comment.