Here are the list of Groovy Script which can be used in Jenkins to automate the JOBs and CI process. Please add your list in the comment sections as well.
Main Source –
- https://github.com/scmgalaxy/jenkins-groovy-script-example
- https://github.com/cloudbees/jenkins-scripts
- https://wiki.jenkins.io/display/JENKINS/Jenkins+Script+Console
- https://pghalliday.com/jenkins/groovy/sonar/chef/configuration/management/2014/09/21/some-useful-
- jenkins-groovy-scripts.html
- https://github.com/cloudbees/jenkins-scripts
- https://github.com/jenkinsci/jenkins-scripts
- https://gist.github.com/dnozay/e7afcf7a7dd8f73a4e05
- https://github.com/samrocketman/jenkins-bootstrap-shared
- https://github.com/samrocketman/jenkins-script-console-scripts
Example Groovy Script
- Activate Chuck Norris Plugin — This script activates Chuck Norris plugin for all jobs in your Jenkins server
- Add a Maven Installation, Tool Installation, Modify System Config
- Add a new label to slaves meeting a condition — This script shows how to alter the slave nodes’ label membership. In this case we create a new label if the existing label contains a string. It has been tested from the Jenkins command window.
- Add notification plugin to every job — This script will add the Notification Plugin to every job.
- Allow broken build claiming on every jobs — With the following simple script, you can activate the option on every jobs of your server in just one go.
- Batch-Update Mercurial branch that is checked out — Updates for multiple jobs which branch will be checked out from Hg
- Bulk rename projects
- Change JVM Options in all Maven tasks of Freestyle Jobs — This script find all Maven Tasks registered in freestyle jobs and replace JVM Options by a new value.
- Change publish over SSH configuration
- Change SCMTrigger for each project to disable during the night and the week-end — This script lets you easily change all jobs running every minutes so that it gets disabled between 21:00 and 07:00 and on Saturday and Sunday.
- Change Version-Number in SVN-path
- Clone all projects in a View — This script enumerates all projects belonging to a specific view and clones them.
- Convert standard mail notifications to use the Mail-Ext Publisher plugin — This script replace mail notifications in all projects by Mail-Ext publisher plugin and re-uses existing recipients.
- Delete .tmp files left in workspace-files — This scripts deletes all the tmp files left in workspace-files directory after the build. On windows servers, this seems pretty common so we run this script on daily basis.
- Delete workspace for all disabled jobs — Deletes the workspace for all disabled jobs to save space
- Disable all jobs — This script disables all jobs in your Jenkins server
- Display Information About Nodes — This scripts displays a bunch of information about all the slave nodes.
- Display job parameters — This scripts displays the parameters for all the jobs along with their default values (if applicable).
- Display jobs group by the build steps they use
- Display list of projects that were built more than 1 day ago. — This script to display list of projects that were built more than 1 day ago.
- Display mail notifications recipients — This script displays for all jobs the list of mail recipients used for notifications.
- Display monitors status — Jenkins uses monitors to validate various behaviors. If you dismiss one, Jenkins will never propose you to reactivate it. This script allows you to check the status of all monitors and to reactive them.
- Display timer triggers — This scripts displays the timer triggers for all the jobs in order to better arrange them.
- Display Tools Location on All Nodes — This script can help to get Jenkins tools localtion on all your slaves
- Enable Timestamper plugin on all jobs — With the following simple script, you can activate the option on every jobs of your server in just one go.
- Failed Jobs — This scripts displays a list of all failed jobs. Addon: restart them.
- Find builds currently running that has been executing for more than N seconds
- Grant Cancel Permission for user and group that have Build permission — This script will go through all groups and users in both Global security and per job security settings.
- Invalidate Jenkins HTTP sessions — This script can monitor and invalidate HTTP sessions if there are many open ones on your server.
- Manually run log rotation on all jobs — Runs log rotation on all jobs to free space
- Monitor and Restart Offline Slaves — This script can monitor and restart offline nodes if they are not disconnected manually.
- Monitoring Scripts — Several scripts to display data about http sessions, threads, memory, JVM or MBeans, when using the Monitoring plugin.
- Parameterized System Groovy script — This script will demonstrate how to get parameters in a system groovy script.
- Preselect username in Maven Release Build
- Printing a list of credentials and their IDs
- Remove all disabled modules in Maven jobs — To remove all disabled modules in Maven jobs
- Remove Deployed Artifacts Actions — This script is used to remove the Deployed Artifacts list that is uselessly stored for each build by the Artifact Deployer Plugin.
- Remove Git Plugin BuildsByBranch BuildData — This script is used to remove the static list of BuildsByBranch that is uselessly stored for each build by the Git Plugin.
- Set GitBlitRepositoryBrowser with custum settings on all repos — This scripts allows to update the repo browser. Can be adapted to any other browser, not only gitblit.
- Update maven jobs to use the post build task to deploy artifacts — This script updates all maven jobs having a deploy goal by install and activate the post build step to deploy artifacts at the end of the build
- Update SVN Browser
- Wipe out workspaces of all jobs — This script wipes out the workspaces of all jobs on your Jenkins server
- Wipe workspaces for a set of jobs on all nodes — The script wipes workspaces of certain jobs on all nodes
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-1
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-2
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-3
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-4
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-5
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-6
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-7
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-8
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-9
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-10
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-11
Latest posts by Rajesh Kumar (see all)
- Best AI tools for Software Engineers - November 4, 2024
- Installing Jupyter: Get up and running on your computer - November 2, 2024
- An Introduction of SymOps by SymOps.com - October 30, 2024