How to retrieve Jenkins build parameters using the Groovy API?

前端 未结 10 2158
忘掉有多难
忘掉有多难 2020-12-09 07:55

I have a parameterized job that uses the Perforce plugin and would like to retrieve the build parameters/properties as well as the p4.change property that\'s set by the Perf

10条回答
  •  离开以前
    2020-12-09 08:15

    Regarding parameters:

    See this answer first. To get a list of all the builds for a project (obtained as per that answer):

    project.builds
    

    When you find your particular build, you need to get all actions of type ParametersAction with build.getActions(hudson.model.ParametersAction). You then query the returned object for your specific parameters.

    Regarding p4.change: I suspect that it is also stored as an action. In Jenkins Groovy console get all actions for a build that contains p4.change and examine them - it will give you an idea what to look for in your code.

提交回复
热议问题