Skip to content

Instantly share code, notes, and snippets.

@dasgoll
Created September 16, 2018 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dasgoll/be7ce4f62e21a898fe4a9a334dc67f5e to your computer and use it in GitHub Desktop.
Save dasgoll/be7ce4f62e21a898fe4a9a334dc67f5e to your computer and use it in GitHub Desktop.
jenkins-cli username and password
So, looking into the Jenkins CLI docs, it mentions the preferred method of auth is to set up an SSH Public Key in your Jenkins user account, then referencing that with the CLI like:
java -jar /opt/jenkins-cli.jar -s "http://localhost:8080" -i path/to/key.rsa who-am-i
Digging down deeper into the CLI jarfile options, I found that the username/password combo is still usable with the -auth option:
java -jar /opt/jenkins-cli.jar -s "http://localhost:8080" -auth username:password who-am-i
The docs do state you should use your Jenkins user token if possible, but it's much harder to automate the user setup and token retrieval, than to use a username and password setup by automated build scripts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment