I'm attempting to download build artifacts from Jenkins via curl
in a Bash script. However, I use GitHub for authentication, and even using the API key belonging to an Administrator user, I only get 403
errors and cannot successfully download.
My curl
command is as follows:
curl -u me:myapitoken -k 'https://jenkins.example.com/job/my-project/lastSuccessfulBuild/artifact/output/artifact_name'`
The header output indicates that Jenkins considers me logged in as an Administrator, yet, I get the 403
error and am unable to download the artifact.
< 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
The link works fine in the browser whilst logged into GitHub and Jenkins.
Does anyone have any idea to authenticate via curl
when using GitHub as a primary authentication provider?
So apparently this was due to a bug in the GitHub Authentication plugin. Installing the latest updates has fixed the issue and allowed me to authenticate using the API key.