I am trying to use the jenkins rest api. In the instructions it says I need to have the api key. I have looked all over the configuration pages to find it. How do i get the API key for jenkins?
The API token is available in your personal configuration page. Click your name on the top right corner on every page, then click "Configure" to see your API token.
The Jenkins master authenticates the user against a users' database, in case of a username:password combination, or by comparing tokens with the local user's API token, stored in the user's config. xml file, in case of username:APItoken authentication.
If your Jenkins server requires authentication (and it SHOULD), you'll see a message saying "Authentication Required". The Jenkins API uses HTTP BASIC authentication and requires a username as well as an API token to connect. Then click the box named "Show API Token", and copy the token to your clipboard.
Since Jenkins 2.129 the API token configuration has changed:
You can now have multiple tokens and name them. They can be revoked individually.
Before Jenkins 2.129: Show the API token as follows:
The API token is revealed.
You can change the token by clicking the Change API Token button.
The non UI way to do this post Jenkins 2.129 is:
curl 'https://<jenkinsURL>/me/descriptorByName/jenkins.security.ApiTokenProperty/generateNewToken' \ --data 'newTokenName=foo' \ --user username:Password
which returns:
{ "status": "ok", "data": { "tokenName": "foo", "tokenUuid": "<uuid>", "tokenValue": "<redacted>" } }
Pre Jenkins 2.129
curl http://<username>:<password>@<jenkins-url>/me/configure
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With