'how to generate API token for jenkins from Docker
I created jenkins server from a docker container and trying to setup my jenkins api tokens from a dockerfile so that I don't have to regenerate from whenever I restart or recreate the container. Not sure hoe this can be done. Please share your suggestions.
Solution 1:[1]
I have researched this a lot time. Finally I find a way to do this programmatically But NOT in dockerfile.
you should set user and password in dockerfile. https://www.popularowl.com/jenkins/automating-jenkins-install-docker-terraform/
get crumb and cookie using this api curl -v -X GET http://localhost:8080/crumbIssuer/api/json --user admin:admin
generate token using the follow api curl -X POST 'http://localhost:8080/user/admin/descriptorByName/jenkins.security.ApiTokenProperty/generateNewToken'
-H 'Cookie: JSESSIONID.1a27c20d=node02jg4glfuhga8aijcxtxezlyf15.node0; Path=/; HttpOnly'
-H 'Jenkins-Crumb: 12f10c096677087e5f97170c8f0b8e52cb83ce49cb5e996ac13a8bc88dcbb254'
--data 'newTokenName=foo'
--user admin:admin
Hope this can help you
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | binglong li |