3

Given i.e. this code::

...
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);
...

how can I specify build parameters for a parametrized jenkins build? adding i.e. arguments.add("-p options.properties=system.props"); to the list doesn't work /message is '

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

'/

What I am trying to achieve above works fine from command line :::

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

1 Answer 1

3

to answer my own question::

apparently parameters and parameter values must go into the list as separate entries. The below code will asynchronously invoke a remote jenkins build with 2 parameters, print the console output and return the exit code;

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.