Jenkins CLI and the Credentials Plugin
A few months ago I was working on a project which involved building an application estate on the AWS platform, with all the infrastructure scripted using CloudFormation. Part of this included a Jenkins server for building and deploying the applications.
This Jenkins instance was an EC2 server, and part of the install process was using the cloud-init definitions to include plugins if they were not already installed, as well as adding the Jenkins jobs themselves.
One thing I was trying to get working, and failed on, was using the Jenkins CLI to configure the credentials plugin. Each attempt to run a command would have the same result, a return code of “255” with no errors displayed on the client.
MacBook:temp dhutchison$ java -jar jenkins-cli.jar -s http://procent.local:8080 -auth jenkinsuser:supersecurepassword list-credentials system::system::jenkins
MacBook:temp dhutchison$ echo $?
255
I revisited this the other day, and encountered the same issue when using a fresh Jenkins docker image and configuring it through the quick start wizard. After a bit of investigation, the solution to this was frustratingly simple.