Skip to content

Instantly share code, notes, and snippets.

@ryanwoodsmall
Created July 30, 2020 20:59
Show Gist options
  • Save ryanwoodsmall/4bd58d67490b83bc0e9adea2e832f529 to your computer and use it in GitHub Desktop.
Save ryanwoodsmall/4bd58d67490b83bc0e9adea2e832f529 to your computer and use it in GitHub Desktop.
jenkins-token.md
curl 'https://<jenkinsURL>/me/descriptorByName/jenkins.security.ApiTokenProperty/generateNewToken' \
--data 'newTokenName=foo' \
--user username:Password
import jenkins.security.*       
User u = User.get("Myuser")  
ApiTokenProperty t = u.getProperty(ApiTokenProperty.class)  
def token = t.getApiTokenInsecure()
println "token is $token "

should work with Jenkins 2.129+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment