Created
January 18, 2020 08:03
-
-
Save ThabetAmer/e36584b7a64b61b4619fb96dd0055fab to your computer and use it in GitHub Desktop.
Groovy/Jenkins function to list all enabled Jenkins jobs by name.
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 | |
/** | |
* Lists all enabled Jenkins jobs by name. | |
* @author [email protected] | |
* @since Jenkins 2.204.1 | |
* @param Bool includeDisabled to include also disabled jobs, default false (No). | |
* @return String array of jenkins jobs names | |
* | |
*/ | |
import hudson.model.AbstractModelObject | |
def getAllJobs(includeDisabled = false) { | |
return jenkins.model.Jenkins.instance.getAllItems(hudson.model.AbstractItem.class). | |
findAll{includeDisabled ? it : it.disabled==false}.collect{it.fullName} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment