jenkinsci / jenkinsci/java-client-api

Sending POST http request for Job.build(Map<String, String> params, boolean crumbFlag) with crumbFlag=true raised java.lang.IllegalArgumentException: Name may not be null

Aperta
#433 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
913
Fork
466
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi, I am quiet new to Jenkins client API. I'm trying to use the `Job.build` method to kick off a parameterized job with `crumb` flag set to `true`.
However, it threw this exception:
```
java.lang.IllegalArgumentException: Name may not be null
at org.apache.http.util.Args.notNull(Args.java:54)
at org.apache.http.message.BasicHeader.(BasicHeader.java:61)
at com.offbytwo.jenkins.client.JenkinsHttpClient.post(JenkinsHttpClient.java:233)
at com.offbytwo.jenkins.model.Job.build(Job.java:151)
```

Inspecting further in `JenkinsHttpClient.java`, it looks like the issue is with crumb issuer path:
```
Crumb crumb = getQuietly("/crumbIssuer", Crumb.class);
```

Shouldn't this be `crumbIssuer/api/xml` or `crumbIssuer/api/json`??

I can't turn off CSRF in this Jenkins instance, so that's not an option. How can I workaround or fix this issue?

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by reading JenkinsHttpClient.java around the post method and Job.java around Job.build, then reproduce a parameterized build with crumbFlag=true. Inspect the /crumbIssuer request and the resulting header construction; done means the request works with CSRF protection enabled without the reported IllegalArgumentException.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
api
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.