Having spent the last few weeks working in Jenkins, I thought I’d share the steps I use to access and control Jenkins from the command line utilising the jenkins-cli tool.

1. Download the Jenkins CLI client

You can download the Jenkins client directly from your Jenkins server using wget.

export JENKINS_URL="https://jenkins.example.com"
wget -P ~/bin ${JENKINS_URL}/jnlpJars/jenkins-cli.jar

2. Set up your Jenkins Credentials.

You have two options for setting up your Jenkins credentials. You can either set environmental variables, or you can create a credentials file.
To setup environmental variables, set the following:


Then you can create an alias for the Jenkins CLI command:

alias jenkins-cli='java -jar ~/bin/jenkins-cli.jar -s ${JENKINS_URL}'

To create a credentials file, add text in the following format to a file in your home directory (like .jenkins-cli).

cat << EOF >> .jenkins-cli

and then add the auth file to the alias:

alias jenkins-cli='java -jar ~/bin/jenkins-cli.jar -s ${JENKINS_URL}' -auth @/Users/mark.honomichl/.jenkins-cli

That’s it. Now you can run CLI commands to interact with your Jenkins server.