Aaron D. Marasco
Aaron D. Marasco

Reputation: 6748

How to get parameters of another build?

I use parameterized builds in a lot of places. I'd like a pipeline's input to be a build number of a different job. I haven't found a clean way to query Jenkins from within groovy to get the other job's build parameters. Does anybody have a snippet to share?

Upvotes: 3

Views: 2378

Answers (1)

Yuri G.
Yuri G.

Reputation: 4648

This works for me in script console

import hudson.model.ParametersAction

def getParams(String project, String buildNumber){

  def params=[]

  Jenkins.instance.getItem(project).getBuild(buildNumber).getActions(ParametersAction)
  .each { action ->
    action.getParameters().each {
      params << it
    }
  }

  return params
}

Upvotes: 4

Related Questions