Api或命令行访问Jenkins配置设置?

时间:2015-01-05 19:53:21

标签: jenkins jenkins-plugins hudson-plugins

具体来说,我试图访问SeleniumHQ(https://wiki.jenkins-ci.org/display/JENKINS/Seleniumhq+Plugin)jar文件设置。我知道我可以从xml文件解析它,但我希望它像$ {seleniumRunner}一样简单,但事实并非如此。是否有一个更干净的API调用或变量结构,可以为我调用它?

more ../hudson.plugins.seleniumhq.SeleniumhqBuilder.xml
<?xml version='1.0' encoding='UTF-8'?>
<hudson.plugins.seleniumhq.SeleniumhqBuilder_-DescriptorImpl plugin="seleniumhq@0.4-Custom">
  <seleniumRunner>/var/lib/jenkins/tools/selenium-server-standalone-2.44.0.jar</seleniumRunner>
</hudson.plugins.seleniumhq.SeleniumhqBuilder_-DescriptorImpl>

1 个答案:

答案 0 :(得分:0)

您可以使用groovy script console

可以从curl访问

$ curl -d "script=<your_script_here>" http://jenkins/script

example修改了maven配置

a=Jenkins.instance.getExtensionList(hudson.tasks.Maven.DescriptorImpl.class)[0];
b=(a.installations as List);
b.add(new hudson.tasks.Maven.MavenInstallation("MAVEN3", "/home/apache-maven-3", []));
a.installations=b
a.save()