【问题标题】:Jenkins REST API Auth using URL parametersJenkins REST API Auth 使用 URL 参数
【发布时间】:2018-07-02 11:12:15
【问题描述】:

我正在尝试将我的 Jenkins 配置为允许使用 REST API 触发远程作业。如果我使用基本身份验证标头参数传递用户名和密码,我就可以触发作业

-u <username>:<api token> http://localhost:8080/job/kp-push-example/build 

但是,如果我在 url 中传递用户名和 api 令牌,Jenkins 将无法进行身份验证,它使用匿名用户并引发错误,因为匿名用户没有执行工作的优势。

http://<username>:<apitoken>@localhost:8080/job/kp-push-example/build 

以下是错误信息。

<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>

如何配置 Jenkins 以允许 url 基本身份验证? 詹金斯版本:2.129

【问题讨论】:

标签: jenkins


【解决方案1】:

能否请您分享您实际使用的是哪个用户以及它是否具有有效令牌? 还有你是怎么触发的?您是否使用脚本,使用一些 Server-Logic 调用它,...?

这是一个经过测试的 cURL 示例:

curl -s -XPOST 'http://localhost:8080/job/kp-push-example/build?token=TOKEN' -u "admin:0000ADMIN-TOKEN00000"

【讨论】:

    猜你喜欢
    • 2018-07-20
    • 2020-08-29
    • 1970-01-01
    • 1970-01-01
    • 2020-05-27
    • 2020-01-09
    • 2020-05-26
    • 1970-01-01
    • 2021-07-24
    相关资源
    最近更新 更多