Jenkins:403 请求中未包含有效的面包屑

2024-03-05

我配置了詹金斯三角帆 https://en.wikipedia.org/wiki/Spinnaker_(software)如下所示并设置 Spinnaker 管道。

 jenkins:
    # If you are integrating Jenkins, set its location here using the baseUrl
    # field and provide the username/password credentials.
    # You must also enable the "igor" service listed separately.
    #
    # If you have multiple Jenkins servers, you will need to list
    # them in an igor-local.yml. See jenkins.masters in config/igor.yml.
    #
    # Note that Jenkins is not installed with Spinnaker so you must obtain this
    # on your own if you are interested.
    enabled: ${services.igor.enabled:false}
    defaultMaster:
      name: default
      baseUrl: http://server:8080
      username: spinnaker
      password: password

但在尝试运行 Spinnaker 管道时,我看到以下错误。

异常(启动 Jenkins 作业) 403 请求中未包含有效的面包屑


最后,这篇文章帮助我解决了面包屑问题,但仍然确保 Jenkins 免受CSRF https://en.wikipedia.org/wiki/Cross-site_request_forgery attack.

请求中包含无效面包屑问题的解决方案 https://linuxacademy.com/community/posts/show/topic/28964-no-valid-crumb-was-included-in-the-request

基本上,我们需要首先请求带有身份验证的 crumb,然后再次发出以 crumb 作为标头的 POST API 调用并再次进行身份验证。

我就是这样做的

curl -v -X GET http://jenkins-url:8080/crumbIssuer/api/json --user <username>:<password>

得到的答复是,

{
"_class":"hudson.security.csrf.DefaultCrumbIssuer",
"crumb":"0db38413bd7ec9e98974f5213f7ead8b",
"crumbRequestField":"Jenkins-Crumb"
}

然后使用其中包含上述碎屑信息的 POST API 调用。

curl -X POST http://jenkins-url:8080/job/<job-name>/build --user <username>:<password> -H 'Jenkins-Crumb: 0db38413bd7ec9e98974f5213f7ead8b'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Jenkins:403 请求中未包含有效的面包屑 的相关文章

随机推荐