Jenkins drop down list of build names of other job

I would like to list out all successfull build names in the drop down menu that got built by another job. I have seen the links to get all list of build ids in the drop down menu with parametrized and copy artifacts plugins. But I need to list with the actual build names set by Build Setter in the other job. Currently i am able to get list with #55,54,53,52.. etc., But I need to list with build names assigned to these builds that got set by build setter.

Code Snippet:

  • 404 error when building Git project in TFS2013
  • Should you check in your compiled assets to Git?
  • How to put jobs in a category for the Throttle Concurrent Builds plugin for Jenkins
  • Xcode build automation scheduled integration bot setting
  • How can I present a git SHA1 to gnu make?
  • Setting Maven params in Jenkins
  • import jenkins.model.Jenkins
    import hudson.model.AbstractProject
    import hudson.model.Result
    import hudson.util.RunList
    AbstractProject<?, ?> otherJob = Jenkins.getInstance().getItemByFullName("iOS_plugin-5.0-build", AbstractProject.class)
    RunList<?> builds = otherJob.getBuilds().overThresholdOnly(Result.SUCCESS)
    
    def list = builds.limit(5).collect { it.number }
    

    Regards,
    Srinivas

  • “Pretty” Continuous Integration for Python
  • Error 500 during Sonar runner execution on Jenkins
  • How to check if build parameter is available in Jenkinsfile
  • Jenkins and return code from windows batch
  • Jenkins build failed with Revision error
  • Running jenkins gives “package org.junit does not exist”
  • One Solution collect form web for “Jenkins drop down list of build names of other job”

    I can retrieve the build name (set with the Build Name Setter plugin) with the “displayName” property of the build object.

    Here is my working example, as a “Dynamic Choice Parameter” groovy plugin:

    def jobname="build-my-project"
    def list=[]
    hudson.model.AbstractProject<?, ?> otherJob = jenkins.model.Jenkins.getInstance().getItemByFullName(jobname, hudson.model.AbstractProject.class)
    hudson.util.RunList<?> builds = otherJob.getBuilds().overThresholdOnly(hudson.model.Result.SUCCESS)
    builds.limit(20).each{run -> list.add(run.displayName) }
    list
    

    I hope this helps!

    Git Baby is a git and github fan, let's start git clone.