如何使用Groovy API检索Jenkins构建参数? [英] How to retrieve Jenkins build parameters using the Groovy API?
问题描述
我有一个使用Perforce插件的参数化作业,并希望检索构建参数/属性以及由Perforce插件设置的p4.change属性。
如何使用Jenkins Groovy API检索这些属性?
关于参数:
首先查看此答案。要获取项目的所有构建列表(按照该答案获得):
project.builds
当您找到您的特定版本时,您需要获取 ParametersAction with build.getActions(hudson.model.ParametersAction)
。然后您可以查询返回的对象以获取您的特定参数。
关于p4.change:我怀疑它也存储为一个动作。在Jenkins Groovy控制台中,获取包含p4.change并检查它们的构建的所有操作 - 它会让您知道在代码中查找什么。
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 Perforce plugin.
How do I retrieve these properties with the Jenkins Groovy API?
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.
这篇关于如何使用Groovy API检索Jenkins构建参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!