使用 cURL 和 GitHub 身份验证从 Jenkins 下载工件

Download Artifacts from Jenkins with cURL and GitHub Authentication

我正在尝试通过 Bash 脚本中的 curl 从 Jenkins 下载构建工件。但是,我使用GitHub进行身份验证,即使使用属于Administrator用户的API密钥,我也只出现403错误,无法下载成功。

我的curl命令如下:

curl -u me:myapitoken -k 'https://jenkins.example.com/job/my-project/lastSuccessfulBuild/artifact/output/artifact_name'`

header 输出表明 Jenkins 认为我以管理员身份登录,但我收到 403 错误并且无法下载工件。

< HTTP/1.1 403 Forbidden
< Date: Tue, 28 Jun 2016 10:03:55 GMT
< Server: Jetty(winstone-2.9)
< X-Content-Type-Options: nosniff
< X-You-Are-Authenticated-As: <me>
< X-You-Are-In-Group: authenticated
< X-Required-Permission: hudson.model.Hudson.Read
< X-Permission-Implied-By: hudson.security.Permission.GenericRead
< X-Permission-Implied-By: hudson.model.Hudson.Administer
< Cache-Control: no-cache,no-store,must-revalidate
< X-Hudson-Theme: default
< Content-Type: text/html;charset=UTF-8
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< X-Hudson: 1.395
< X-Jenkins: 1.656
< X-Jenkins-Session: fbdxxxxx
< X-Hudson-CLI-Port: 51518
< X-Jenkins-CLI-Port: 51518
< X-Jenkins-CLI2-Port: 51518
< X-Frame-Options: sameorigin
< X-Instance-Identity: MIIBIjANBgkqhkiG9w0B<...>XwIDAQAB
< X-SSH-Endpoint: jenkins.example.com:53605
< Content-Length: 5166
< Set-Cookie: JSESSIONID.xxxxxxx=b2rxxxxxxxxxx5btw3e;Path=/;Secure;HttpOnly

登录 GitHub 和 Jenkins 后,link 在浏览器中工作正常。

有人知道在使用 GitHub 作为主要身份验证提供程序时通过 curl 进行身份验证吗?

显然这是由于 GitHub 身份验证插件中的错误。安装最新更新已解决问题,并允许我使用 API 密钥进行身份验证。