jenkins: simplify timer check (#32254)

simplify timer check
This commit is contained in:
Justin Newberry 2024-04-19 10:03:47 -07:00 committed by GitHub
parent 331c7b103a
commit 0d5dd25db5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 19 deletions

21
Jenkinsfile vendored
View File

@ -9,26 +9,9 @@ def retryWithDelay(int maxRetries, int delay, Closure body) {
throw Exception("Failed after ${maxRetries} retries")
}
// check if started by timer: https://stackoverflow.com/questions/43516025/how-to-handle-nightly-build-in-jenkins-declarative-pipeline
@NonCPS
// check if started by timer: https://gist.github.com/aaclarker/75b8a0eb2b4d600779f84f8e849f2c37
def isJobStartedByTimer() {
def startedByTimer = false
try {
def buildCauses = currentBuild.rawBuild.getCauses()
for ( buildCause in buildCauses ) {
if (buildCause != null) {
def causeDescription = buildCause.getShortDescription()
echo "shortDescription: ${causeDescription}"
if (causeDescription.contains("Started by timer")) {
startedByTimer = true
}
}
}
} catch(theError) {
echo "Error getting build cause"
}
return startedByTimer
return currentBuild.getBuildCauses()[0]["shortDescription"].matches("Started by timer");
}
def device(String ip, String step_label, String cmd) {