Reputation: 10034
I'm trying configure my Jenkins to allow remote job trigger using REST API. If I pass username and password using basic authentication header param, I'm able to trigger the job
-u <username>:<api token> http://localhost:8080/job/kp-push-example/build
However if I pass username and api token in url, Jenkins is unable to authenticate, it uses anonymous user and throws error, as anonymous user does not have prevailage to execute the job.
http://<username>:<apitoken>@localhost:8080/job/kp-push-example/build
Below is the error message.
<html>
<head>
<meta http-equiv='refresh' content='1;url=/login?from=%2Fjob%2Fkp-push-example%2Fbuild'/>
<script>window.location.replace('/login?from=%2Fjob%2Fkp-push-example%2Fbuild');</script>
</head>
<body style='background-color:white; color:white;'>
Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:
Permission you need to have (but didn't): hudson.model.Hudson.Read
... which is implied by: hudson.security.Permission.GenericRead
... which is implied by: hudson.model.Hudson.Administer
-->
</body>
</html>
How to configure Jenkins to allow url basic auth? Jenkins version: 2.129
Upvotes: 3
Views: 8143
Reputation: 1616
Could you please share in which user your are actually using and if it has a valid token? Also how are you triggering it? Are you using a script, call it with some Server-Logic, ...?
Here's a tested and working example for cURL:
curl -s -XPOST 'http://localhost:8080/job/kp-push-example/build?token=TOKEN' -u "admin:0000ADMIN-TOKEN00000"
Upvotes: 2