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

Ouverte
#433 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Java
Étoiles
913
Forks
466
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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?

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
java
Domaine
api
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.