Last active
June 17, 2022 15:34
-
-
Save ThabetAmer/91cc801164a7677c99221e0efdc4b31b to your computer and use it in GitHub Desktop.
Groovy/Jenkins function to return the ID number of last successful build for a specific Jenkins job
This file contains 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
#!/usr/bin/env groovy | |
/** | |
* Gets last successful build number | |
* @author thabet.amer@gmail.com | |
* @since Jenkins 2.204.1 | |
* @param String job name | |
* @return String number of build number | |
* | |
*/ | |
import jenkins.model.Jenkins | |
def getLastSuccessful(jobName) { | |
assert jobName != null | |
return Jenkins.getInstance().getItemByFullName(jobName).lastSuccessfulBuild.number | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment