mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 17:43:54 +08:00
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
This commit is contained in:
32
Jenkinsfile
vendored
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'),
|
||||
|
||||
Reference in New Issue
Block a user