How to (re)generate my Jenkins user token Bee Bot July 13, 2022 13:17 Updated The content of this article has moved to the new documentation site. Related articles How to build a job using the REST API and cURL? Environment How to revoke APIToken after a user left How to manage Credentials via the REST API Groovy to list all jobs Comments 4 comments Sort by Date Votes Discover Bank March 21, 2018 16:23 Is there a way to programmatically generate/rotate the same? Thank you 0 Andrey Kaliazin May 29, 2018 12:48 More generally - how to access/modify the user security parameters - API token, SSH private key etc, via ssh, jenkins cli, rest? Just showing how to do it via GUI is not helpful really. Kind regards 0 Samrat Shaw September 19, 2018 01:16 I have written an article of how we an retrieve the token programmatically. Might be helpful to other. https://medium.com/@samratshaw/programmatically-retrieve-jenkins-rest-api-token-f2c3f0d69483 0 Ra Ge March 26, 2019 02:35 Edited Post Jenkins 2.189, a non-UI way to generate a new token is: ```curl 'https://jenkins-sandbox.internal.renaissance-golabs.com/me/descriptorByName/jenkins.security.ApiTokenProperty/generateNewToken' \--data 'newTokenName=foo' \--user username:Password``` ```{"status": "ok","data": {"tokenName": "foo","tokenUuid": "<uuid>","tokenValue": "<redacted>"}}``` 0 Please sign in to leave a comment.
Comments
4 comments
Is there a way to programmatically generate/rotate the same?
Thank you
More generally - how to access/modify the user security parameters - API token, SSH private key etc, via ssh, jenkins cli, rest?
Just showing how to do it via GUI is not helpful really.
Kind regards
I have written an article of how we an retrieve the token programmatically.
Might be helpful to other.
https://medium.com/@samratshaw/programmatically-retrieve-jenkins-rest-api-token-f2c3f0d69483
Post Jenkins 2.189, a non-UI way to generate a new token is:
```
curl 'https://jenkins-sandbox.internal.renaissance-golabs.com/me/descriptorByName/jenkins.security.ApiTokenProperty/generateNewToken' \
--data 'newTokenName=foo' \
--user username:Password
```
```
{
"status": "ok",
"data": {
"tokenName": "foo",
"tokenUuid": "<uuid>",
"tokenValue": "<redacted>"
}
}
```
Please sign in to leave a comment.