question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] buildWithParameters functionality

See original GitHub issue

I would like to trigger a parametrized build using this library but somehow the parameters are not sent in the request. I have defined an authentication token in the job (trigger by jenkinsServer/job/jobName/buildWithParameters?token=TOKEN) and want to set two parameters to param1=param1value and param2=param2value.

Instead of sending the set parameters, the following code triggers the build with the default parameter values (specified in the jenkins configuration).

// set up client
JenkinsClient client = JenkinsClient.builder()
    .endPoint(jenkinsServer)
    .credentials(Base64encodedCredentials).build();

// set parameters
Map<String, List<String>> params = new HashMap<>();
List<String> tokenList = new ArrayList<>();
List<String> paramList1 = new ArrayList<>();
List<String> paramList2 = new ArrayList<>();
tokenList.add(TOKEN);
paramList1.add(param1value);
paramList2.add(param2value);
params.put("token", tokenList);
params.put("param1", param1List);
params.put("param2", param2List);

// sending request
IntegerResponse response = client.api().jobsApi()
        .buildWithParameters(null, jobName, params);

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
iskercommented, Jun 6, 2019

@cdancy I ran into this problem myself in #62. I don’t think either of the forms of authentication on JenkinsClient.Builder are substitutes for the token query parameter. The query parameter is a per-job authentication mechanism, whereas the Bearer/Basic auth mechanisms on JenkinsClient are for global access. You can’t use the per-job token in either of these cases.

See examples on https://wiki.jenkins.io/display/JENKINS/Authenticating+scripted+clients for its usage or the python jenkinsapi job invocation method https://github.com/pycontribs/jenkinsapi/blob/6d3bf94b34a521955dbb82c5ae7c2eba031af894/jenkinsapi/job.py#L175-L184

1reaction
damian-tcommented, Jan 24, 2019

The job itself is not failing, it is just ignoring the parameters of the request. While debugging, I looked at the GeneratedHttpRequest object. Method is “POST”, URI is: jenkinsServer/job/jobName/buildWithParameters, with payload-content: "param2=param2value&param1=param1value&token=TOKEN". To me, this looks more like query params actually… Moreover, I believe the order of query params is important. When I use curl to send the request (with token not immediately following buildWithParameters, the other parameters are also ignored.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the question mark for in a Typescript parameter name
It is to mark the parameter as optional. TypeScript handbook https://www.typescriptlang.org/docs/handbook/2/functions.html#optional-parameters ...
Read more >
can anyone tell me what is the functionality of parameter ...
can anyone tell me what is the functionality of parameter 'save_new' in vf page URL? Ask Question. Asked 5 years, 9 months ago....
Read more >
5.24. Functions and Strings Write Code Questions
Write a function called start_a that takes in string as a parameter and returns True if the string starts with a lowercase a...
Read more >
Solved Functional Parameter approach to this program as
Question: Functional Parameter approach to this program as shown below: 2. Write a program that will make simple English-Metric conversions of lengths.
Read more >
Parameter Functions Question: Rounding Up OR Down
Parameter Functions Question: Rounding Up OR Down ... I want in one direction or the other (rounding up or down) using the ceil()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found