Script to List Key Job Settings in Jenkins at a Glance

One can get addicted to scripting in Jenkins quickly!😉

When you have dozens even hundreds of jobs in Jenkins, it is really important to have a way to review or change job settings in one shot. One of my favorite scripts, that I use when I want to get key settings from all jobs at a glance, is this one:

import hudson.model.*
import hudson.maven.*

for (job in Hudson.instance.items) {
  if (job instanceof MavenModuleSet) {
    mms = (MavenModuleSet) job
    def name = mms.name
    def jdk = "def"
    if (mms.JDK != null) {
      jdk = mms.JDK.name
    }
    def mvn = mms.mavenName
    def goals = mms.goals
    printf("%-50s | %-10s | %-15s | %-50s\n", name, jdk, mvn, goals)
  }
}

And this is a example output. I love it!😀  (Be sure to scroll right to see full output.)

deors.demos.annotations.base                       | jdk-8      | null            | clean install                                     
deors.demos.annotations.base.client                | jdk-8      | null            | clean test                                        
deors.demos.annotations.base.processors            | jdk-8      | null            | clean install                                     
deors.demos.annotations.beaninfo                   | jdk-8      | null            | clean install                                     
deors.demos.annotations.beaninfo.client            | jdk-8      | null            | clean test                                        
deors.demos.annotations.beaninfo.processors        | jdk-8      | null            | clean install                                     
deors.demos.annotations.velocity.client            | jdk-8      | null            | clean test                                        
deors.demos.annotations.velocity.processors        | jdk-8      | null            | clean install                                     
deors.demos.batch.springbatch2                     | jdk-7      | maven-3.2.1     | clean verify                                      
deors.demos.cloud.gae                              | jdk-7      | maven-3.2.1     | clean verify                                      
deors.demos.cloud.heroku                           | jdk-7      | maven-3.2.1     | clean verify                                      
deors.demos.cloud.rhc                              | jdk-7      | maven-3.2.1     | clean verify                                      
deors.demos.cloud.vmc                              | jdk-7      | maven-3.2.1     | clean verify                                      
deors.demos.java8                                  | jdk-8      | maven-3.2.1     | clean verify                                      
deors.demos.testing.arquillian                     | jdk-7      | maven-3.2.1     | clean verify                                      
deors.demos.testing.arquillian-glassfish-embedded  | jdk-7      | null            | clean verify -Parquillian-glassfish-embedded      
deors.demos.testing.arquillian-glassfish-remote    | jdk-7      | null            | clean verify -Parquillian-glassfish-remote,!arquillian-glassfish-embedded
deors.demos.testing.arquillian-jboss-managed       | jdk-7      | null            | clean verify -Parquillian-jboss-managed,!arquillian-glassfish-embedded
deors.demos.testing.arquillian-jboss-remote        | jdk-7      | null            | clean verify -Parquillian-jboss-remote,!arquillian-glassfish-embedded
deors.demos.testing.arquillian-weld-embedded       | jdk-7      | null            | clean verify -Parquillian-weld-embedded,!arquillian-glassfish-embedded
deors.demos.testing.htmlunit                       | jdk-7      | maven-3.2.1     | clean verify                                      
deors.demos.testing.htmlunit-cargo-glassfish       | jdk-7      | null            | -P glassfish cargo:redeploy                       
deors.demos.testing.htmlunit-cargo-jboss           | jdk-7      | null            | -P jboss cargo:redeploy                           
deors.demos.testing.htmlunit-cargo-tomcat          | jdk-7      | null            | -P tomcat cargo:redeploy                          
deors.demos.testing.htmlunit-deploy-glassfish      | jdk-7      | null            | clean install                                     
deors.demos.testing.htmlunit-deploy-tomcat         | jdk-7      | null            | clean install                                     
deors.demos.testing.mocks                          | jdk-7      | maven-3.2.1     | clean verify                                      
deors.demos.testing.selenium                       | jdk-7      | maven-3.2.1     | clean verify                                      
deors.demos.testing.selenium-cargo-glassfish       | jdk-7      | null            | -P glassfish cargo:redeploy                       
deors.demos.testing.selenium-cargo-jboss           | jdk-7      | null            | -P jboss cargo:redeploy                           
deors.demos.testing.selenium-cargo-tomcat          | jdk-7      | null            | -P tomcat cargo:redeploy                          
deors.demos.testing.selenium-deploy-glassfish      | jdk-7      | null            | clean install                                     
deors.demos.testing.selenium-deploy-tomcat         | jdk-7      | null            | clean install                                     
deors.demos.web.gwt2                               | jdk-7      | maven-3.2.1     | clean verify                                      
deors.demos.web.gwt2spring                         | jdk-7      | maven-3.2.1     | clean verify                                      
deors.demos.web.springmvc3                         | jdk-7      | maven-3.2.1     | clean verify                                      
petclinic-1-build-test                             | jdk-7      | maven-3.2.1     | clean test                                        
petclinic-2-package                                | jdk-7      | null            | package -DskipTests=true                          
petclinic-3-tomcat-run                             | jdk-7      | null            | cargo:run -Pcargo-tomcat                          
petclinic-4-verify-selenium-htmlunit               | jdk-7      | maven-3.2.1     | failsafe:integration-test -P selenium-tests       
petclinic-5-verify-jmeter                          | jdk-7      | maven-3.2.1     | jmeter:jmeter -P jmeter-tests                     
petclinic-6-tomcat-stop                            | jdk-7      | null            | cargo:stop -Pcargo-tomcat                         
petclinic-9a-verify-selenium-openshift             | jdk-7      | maven-3.2.1     | failsafe:integration-test -P selenium-tests       
petclinic-9b-verify-selenium-heroku                | jdk-7      | maven-3.2.1     | failsafe:integration-test -P selenium-tests       
petclinic-full-all-browsers                        | jdk-7      | maven-3.2.1     | clean verify -P cargo-tomcat,selenium-tests       
petclinic-full-htmlunit-sonar                      | jdk-7      | maven-3.2.1     | clean verify -P cargo-tomcat,selenium-tests,jmeter-tests

Author: deors

senior technology architect in accenture, with a passion for technology related stuff, celtic music and the best sci-fi, among other thousand things!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s