Skip to main content

Jenkins Groovy script: List all jobs

Answered

Comments

4 comments

  • Official comment
    Ryan Wren

    This script will provide that information for you:

    Jenkins.instance.getAllItems(AbstractItem.class).eachWithIndex{ it, index ->
    if(it == Jenkins.instance.getAllItems(AbstractItem.class).last()) {
    println(index + " total jobs\n")
    }
    }

    Jenkins.instance.getAllItems(AbstractItem.class).each{
    println(it.fullName)
    }

    For more context - https://support.cloudbees.com/hc/en-us/articles/226941767-Groovy-to-list-all-jobs

  • Raja Maganti

    Thanks Ryan.

    I am sorry . I need a script to count the number of Jenkins Jobs.

     

    0
  • Ryan Wren

    If you navigate to the Manage Jenkins -> Script Console page on your Jenkins master, copy/paste the Groovy script in my previous comment, and run the script - you will see the number of jobs as well as the list of jobs.

    0
  • Rameshmari Please Update

    how to copy a folder to another location of the folder

    0

Please sign in to leave a comment.

About CloudBees Support

Our Support Engineers are available to help with any questions or problems you may have with any of our products.