Created
October 24, 2023 14:26
-
-
Save jimklimov/4c489b7ccbd5ce89b293cea483b9f6fd to your computer and use it in GitHub Desktop.
Jenkins - investigate job causes (e.g. to find SCM sources)
This file contains hidden or 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
// Paste to your JENKINS_URL/script console: | |
def job = Jenkins.instance.getItemByFullName("org/repo/branch") | |
println "job: ${job}" | |
def build = job.getBuildByNumber(123) | |
println build | |
def commitHashForBuild(build) { | |
def scmAction = null | |
build?.actions.each { action -> | |
println "action: <${action?.getClass()}>'${action}'" | |
if (action instanceof jenkins.scm.api.SCMRevisionAction) | |
scmAction = action | |
} | |
println "scmAction: <${scmAction?.getClass()}>'${scmAction}'" | |
println "scmAction.revision: <${scmAction?.revision?.getClass()}>'${scmAction?.revision}'" | |
println "scmAction.revision.hash: <${scmAction?.revision?.hash?.getClass()}>'${scmAction?.revision?.hash}'" | |
return scmAction?.revision?.hash | |
} | |
println commitHashForBuild(build) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment