In Groovy, how do I get the list of parameter names for a given job?

点点圈 提交于 2019-12-13 04:52:59

问题


In Groovy, I get my hands on a Hudson job:

def job = hudson.model.Hudson.instance.getItem("Rsync library to docs-stage") 

Now I would like to have a list of the parameter names for that job. Sounds simple, but Googling around isn't getting me there yet. Could someone enlighten me?

Thanks.


回答1:


I'n not sure what you mean by "parameter names." As a last resort, you can get the configuration of the job as an XML String:

print job.configFile.asString()

Since this is XML, you can parse it as needed. Depending on what parameter names you are looking for, you can probably also get them directly in Java. Can you post the XML for what you are looking for? That will help in commenting on a better way.

For the parameters needed by this poster, it is easy to get using Groovy:

def params = job.getProperty('hudson.model.ParametersDefinitionProperty')
  .parameterDefinitions

params.each { p -> println "$p.name"}


来源:https://stackoverflow.com/questions/29954975/in-groovy-how-do-i-get-the-list-of-parameter-names-for-a-given-job

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!