Skip to content

Instantly share code, notes, and snippets.

View ThabetAmer's full-sized avatar
🎯
In the search for a new challenge!

Thabet Amer ThabetAmer

🎯
In the search for a new challenge!
View GitHub Profile
@ThabetAmer
ThabetAmer / get-jobs.groovy
Created January 18, 2020 08:03
Groovy/Jenkins function to list all enabled Jenkins jobs by name.
#!/usr/bin/env groovy
/**
* Lists all enabled Jenkins jobs by name.
* @author thabet.amer@gmail.com
* @since Jenkins 2.204.1
* @param Bool includeDisabled to include also disabled jobs, default false (No).
* @return String array of jenkins jobs names
*
*/
@ThabetAmer
ThabetAmer / get-envvars.groovy
Last active January 18, 2020 08:02
Groovy Function for Jenkins pipelines
#!/usr/bin/env groovy
/**
* Reads environment variables from a property file, and loads them into Jenkins ENV
* @author thabet.amer@gmail.com
* @since Jenkins 2.204.1
* @param String path
* @return String array
*
* Example property file:
@ThabetAmer
ThabetAmer / get-last-successful-build-no.groovy
Last active June 17, 2022 15:34
Groovy/Jenkins function to return the ID number of last successful build for a specific Jenkins job
#!/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
*
*/
@ThabetAmer
ThabetAmer / list-git-branches.groovy
Last active February 9, 2023 16:08
Jenkins Groovy script to read Git repo branches and list them in an array, can be suited with Active Choice Jenkins Plugin
#!/usr/bin/env groovy
/**
* List all Git branches of a repo.
* @author thabet.amer@gmail.com
* @since Jenkins 2.204.1
* @params String url for Git repo URL, String credentialID, Bool activeChoice if ActiveChoice plugin used, String defaultBranch
* @return String array of branch names
*
* Dependencies: