Created
September 17, 2018 19:29
-
-
Save NOX73/4ee344e5d091e61420a738469c3af144 to your computer and use it in GitHub Desktop.
Jenkins Groovy Build only last script
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
| import hudson.model.* | |
| def action = hudson.plugins.git.util.BuildData.class | |
| def currentBuild = this.build | |
| def buildname = currentBuild.getDisplayName() | |
| def revision = currentBuild.getAction(action).lastBuiltRevision.sha1String | |
| def jobname = 'taxdome-features' | |
| def job = currentBuild.project | |
| // def job = Hudson.instance.getJob(jobname) | |
| for (build in job.builds) { | |
| if (!build.isBuilding()) { continue; } | |
| if (build == this.build) { continue; } | |
| if (buildname != build.getDisplayName()) { continue; } | |
| if(revision == build.getAction(action).lastBuiltRevision.sha1String) { | |
| println "Stopping self build ${Hudson.instance.getRootUrl()+build.getUrl()} ..." | |
| currentBuild.doStop(); | |
| currentBuild.delete(); | |
| } else { | |
| println "Stopping same build ${Hudson.instance.getRootUrl()+build.getUrl()} ..." | |
| build.doStop(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment