gpt4 book ai didi

java - Jenkins CLI Java API - 指定构建参数

转载 作者:行者123 更新时间:2023-12-04 05:12:24 24 4
gpt4 key购买 nike

鉴于此代码::

...
List<String> arguments = new LinkedList<String>();
arguments.add("build");
arguments.add(projectName);
arguments.add("-s");
arguments.add("-v");
CLI cli = new CLI(new URL(url));
cli.upgrade();
int exit_code = cli.execute(arguments);
...

如何为参数化的 jenkins 构建指定构建参数?添加即 arguments.add("-p options.properties=system.props"); 到列表不起作用/message is '

-p options.properties=system.props is not a valid option

'/

我正在努力实现的上述目标在命令行中运行良好:::

java -jar jenkins-cli.jar -s http://localhost:8080/jenkins build mvn_project01 -p options.properties=system.props

最佳答案

回答我自己的问题::

显然参数和参数值必须作为单独的条目进入列表。下面的代码将异步调用带有 2 个参数的远程 jenkins 构建,打印控制台输出并返回退出代码;

List<String> arguments = new LinkedList<String>();
arguments.add("build");
arguments.add(projectName);

arguments.add("-p");
arguments.add("options.properties=system.props");
arguments.add("-p");
arguments.add("anotherOption=optionValue");

arguments.add("-s");
arguments.add("-v");
CLI cli = new CLI(new URL(url));
cli.upgrade();
int exit_code = cli.execute(arguments);

关于java - Jenkins CLI Java API - 指定构建参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14736125/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com