我按如下方式在大三角帆中配置了 jenkins 并设置了大三角帆管道。

 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
但是我在尝试运行大三角帆管道时看到以下错误。

最佳答案

最后,这篇文章帮助我解决了 crumb 问题,但仍然保护 Jenkins 免受 CSRF 攻击。

Solution for no-valid crumb included in the request issue

基本上,我们需要首先请求带有身份验证的 crumb,然后再次发出带有 crumb 作为 header 的 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'

关于 Jenkins :403 请求中没有包含有效的面包屑,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44711696/

10-13 04:36