I am trying to get the last successful build from a job in jenkins so that when another condition is meet details from that build will then be passed to another job. I am trying to use Hudson's Run class since it has methods to get the last successful build, but I can't get it to compile. Since all my builds have failed, for now I am using getPreviousFailedBuild() instead, but it will be swapped for successful build later. Currently I have this:
import hudson.model.Run.*
def lastFailedBuild = getPreviousFailedBuild()
currently I get this error message when I try and run my script
Caught: groovy.lang.MissingMethodException: No signature of method: hudson7682146427918660061.getPreviousFailedBuild() is applicable for argument types: () values: [] at hudson7682146427918660061.run(hudson7682146427918660061.groovy:5)
I was getting errors with the import statement till I added the .*
at the end, and I also tried calling the method like this: Run.getPreviousFailedBuild()
However that would result in a no such property Run exception instead.
What do I need to have in order to access my previous builds Hudson classes so I can send on the info I need to.
使用execute system groovy script
def lastSuccess = build.getProject().getLastSuccessfulBuild()
import jenkins.model.Jenkins
def test_job = Jenkins.instance.getItemByFullName("My-Test-Dev")
last_sucessful_build_number=test_job.getLastSuccessfulBuild().getNumber()
println last_sucessful_build_number
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.