Jenkins
Jenkins Commands Cheat Sheet
Practical Jenkins commands for jobs, builds, pipelines, agents, plugins, credentials, logs, REST API, CI/CD and troubleshooting.
Jenkins Command Categories
Jump directly to the Jenkins commands you need.
Jenkins CLI and Server
5 commands
View commands →Jobs
6 commands
View commands →Builds
5 commands
View commands →Parameterized Builds
3 commands
View commands →Pipelines
7 commands
View commands →Pipeline Environment and Parameters
5 commands
View commands →Agents and Nodes
4 commands
View commands →Plugins
6 commands
View commands →Credentials
4 commands
View commands →Logs and Console Output
4 commands
View commands →REST API
5 commands
View commands →Jenkins Environment Variables
6 commands
View commands →Workspace and Cleanup
4 commands
View commands →Jenkins Administration
6 commands
View commands →Build Control
3 commands
View commands →CI/CD Workflow
6 commands
View commands →Jenkins Troubleshooting
6 commands
View commands →Showing 85 commands across 17 categories.
Jenkins CLI and Server
5 commandsjava -jar jenkins-cli.jar -s http://localhost:8080/ helpDisplay available Jenkins CLI commands.
java -jar jenkins-cli.jar -s http://localhost:8080/ versionDisplay the Jenkins CLI/server version.
java -jar jenkins-cli.jar -s http://localhost:8080/ who-am-iDisplay the authenticated Jenkins user.
java -jar jenkins-cli.jar -s http://localhost:8080/ help buildDisplay help for the Jenkins build CLI command.
java -jar jenkins-cli.jar -s http://localhost:8080/ help consoleDisplay help for the Jenkins console CLI command.
Jobs
6 commandsjava -jar jenkins-cli.jar -s http://localhost:8080/ list-jobsList Jenkins jobs visible to the authenticated user.
java -jar jenkins-cli.jar -s http://localhost:8080/ create-job my-jobCreate a Jenkins job from XML supplied through standard input.
java -jar jenkins-cli.jar -s http://localhost:8080/ get-job my-jobRetrieve the XML configuration of a Jenkins job.
java -jar jenkins-cli.jar -s http://localhost:8080/ update-job my-jobUpdate an existing Jenkins job using XML configuration.
java -jar jenkins-cli.jar -s http://localhost:8080/ copy-job old-job new-jobCreate a new job by copying an existing Jenkins job.
java -jar jenkins-cli.jar -s http://localhost:8080/ delete-job my-jobDelete a Jenkins job.
Builds
5 commandsjava -jar jenkins-cli.jar -s http://localhost:8080/ build my-jobTrigger a Jenkins job build.
java -jar jenkins-cli.jar -s http://localhost:8080/ build my-job -sTrigger a build and wait until the build starts.
java -jar jenkins-cli.jar -s http://localhost:8080/ build my-job -fTrigger a build and wait until it finishes.
java -jar jenkins-cli.jar -s http://localhost:8080/ build my-job -p VERSION=1.0Trigger a parameterized Jenkins build with a parameter value.
java -jar jenkins-cli.jar -s http://localhost:8080/ console my-jobDisplay the console output of a Jenkins job's latest build.
Parameterized Builds
3 commandsjava -jar jenkins-cli.jar -s http://localhost:8080/ build my-job -p ENV=productionTrigger a build with a string parameter.
java -jar jenkins-cli.jar -s http://localhost:8080/ build my-job -p BRANCH=mainTrigger a build using a Git branch parameter.
java -jar jenkins-cli.jar -s http://localhost:8080/ build my-job -p IMAGE_TAG=v1.2.0Pass an image tag to a Jenkins build.
Pipelines
7 commandsjava -jar jenkins-cli.jar -s http://localhost:8080/ get-job my-pipelineRetrieve the configuration of a Jenkins Pipeline job.
java -jar jenkins-cli.jar -s http://localhost:8080/ build my-pipelineTrigger a Jenkins Pipeline build.
java -jar jenkins-cli.jar -s http://localhost:8080/ console my-pipelineDisplay console output from the Pipeline's latest build.
pipeline { agent any }Define a Declarative Jenkins Pipeline that can execute on any available agent.
stage('Build') { steps { sh 'npm run build' } }Define a Pipeline stage that executes a build command.
sh 'docker build -t myapp .'Execute a shell command from a Jenkins Pipeline on a Unix-like agent.
bat 'docker build -t myapp .'Execute a Windows batch command from a Jenkins Pipeline.
Pipeline Environment and Parameters
5 commandsenvironment { APP_ENV = 'production' }Define environment variables for a Declarative Pipeline.
parameters { string(name: 'BRANCH', defaultValue: 'main') }Define a string parameter for a Jenkins Pipeline.
echo "${env.BUILD_NUMBER}"Print the current Jenkins build number from a Pipeline.
echo "${params.BRANCH}"Read a Pipeline parameter.
withCredentials([...])Temporarily expose configured Jenkins credentials to Pipeline steps.
Agents and Nodes
4 commandsjava -jar jenkins-cli.jar -s http://localhost:8080/ list-nodesList Jenkins agents/nodes available to the authenticated user.
java -jar jenkins-cli.jar -s http://localhost:8080/ get-node node1Display configuration information for a Jenkins node.
java -jar jenkins-cli.jar -s http://localhost:8080/ offline-node node1 -m "Maintenance"Mark a Jenkins node offline with a maintenance message.
java -jar jenkins-cli.jar -s http://localhost:8080/ online-node node1Bring a Jenkins node back online.
Plugins
6 commandsjava -jar jenkins-cli.jar -s http://localhost:8080/ list-pluginsList installed Jenkins plugins.
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin workflow-aggregatorInstall a Jenkins plugin by its short name.
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin gitInstall the Jenkins Git plugin.
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin docker-workflowInstall the Jenkins Docker Pipeline integration plugin.
java -jar jenkins-cli.jar -s http://localhost:8080/ restartRestart Jenkins after plugin or configuration changes when permitted.
java -jar jenkins-cli.jar -s http://localhost:8080/ safe-restartRestart Jenkins after running builds have completed.
Credentials
4 commandswithCredentials([usernamePassword(...)])Use a configured username/password credential securely inside a Pipeline.
withCredentials([string(...)])Use a configured secret text credential inside a Pipeline.
withCredentials([file(...)])Use a configured secret file credential inside a Pipeline.
credentials('docker-registry')Reference a Jenkins credential from a Declarative Pipeline.
Logs and Console Output
4 commandsjava -jar jenkins-cli.jar -s http://localhost:8080/ console my-jobDisplay the latest console output for a job.
java -jar jenkins-cli.jar -s http://localhost:8080/ console my-job 25Display console output for a specific build number.
java -jar jenkins-cli.jar -s http://localhost:8080/ console my-job -fFollow console output while a build is running.
echo "Build ${env.BUILD_NUMBER}"Print build information to the Jenkins Pipeline console.
REST API
5 commandscurl http://localhost:8080/api/jsonRetrieve Jenkins information through the JSON REST API.
curl http://localhost:8080/job/my-job/api/jsonRetrieve JSON information about a specific Jenkins job.
curl http://localhost:8080/job/my-job/lastBuild/api/jsonRetrieve information about the latest build of a Jenkins job.
curl http://localhost:8080/job/my-job/lastBuild/consoleTextRetrieve plain-text console output from the latest build.
curl -X POST http://localhost:8080/job/my-job/buildTrigger a Jenkins build through the REST API when authentication and permissions allow it.
Jenkins Environment Variables
6 commandsecho $BUILD_NUMBERDisplay the current Jenkins build number from a Unix-like shell.
echo $BUILD_IDDisplay the current Jenkins build identifier.
echo $BUILD_URLDisplay the URL of the current Jenkins build.
echo $JOB_NAMEDisplay the current Jenkins job name.
echo $WORKSPACEDisplay the workspace directory on the Jenkins agent.
echo $GIT_COMMITDisplay the Git commit associated with the build when Git integration provides it.
Workspace and Cleanup
4 commandsdeleteDir()Delete the current Pipeline workspace contents.
cleanWs()Clean the Jenkins workspace when the Workspace Cleanup plugin is available.
dir('frontend') { ... }Execute Pipeline steps inside a specific workspace directory.
ws('/custom/workspace') { ... }Execute Pipeline steps using a specified workspace location.
Jenkins Administration
6 commandsjava -jar jenkins-cli.jar -s http://localhost:8080/ reload-configurationReload Jenkins configuration from disk.
java -jar jenkins-cli.jar -s http://localhost:8080/ reload-job my-jobReload a job configuration from disk when applicable.
java -jar jenkins-cli.jar -s http://localhost:8080/ quiet-downPrevent new builds from starting while Jenkins completes existing work.
java -jar jenkins-cli.jar -s http://localhost:8080/ cancel-quiet-downCancel quiet-down mode and allow new builds to start.
java -jar jenkins-cli.jar -s http://localhost:8080/ restartRestart the Jenkins controller.
java -jar jenkins-cli.jar -s http://localhost:8080/ safe-restartRestart Jenkins after running builds have completed.
Build Control
3 commandsjava -jar jenkins-cli.jar -s http://localhost:8080/ stop-builds my-jobStop builds for a job when supported by the installed Jenkins CLI command set.
java -jar jenkins-cli.jar -s http://localhost:8080/ build my-job -fTrigger a build and wait for its completion.
java -jar jenkins-cli.jar -s http://localhost:8080/ console my-job -fFollow live console output from the latest build.
CI/CD Workflow
6 commandscheckout scmCheck out the source code configured for the Jenkins Pipeline.
sh 'npm ci'Install Node.js dependencies in a Unix-like Jenkins agent.
sh 'npm run build'Build a Node.js application in a Jenkins Pipeline.
sh 'docker build -t myapp:${BUILD_NUMBER} .'Build a Docker image using the Jenkins build number as the image tag.
sh 'docker push registry.example.com/myapp:${BUILD_NUMBER}'Push a built Docker image to a container registry.
sh 'kubectl apply -f k8s/'Deploy Kubernetes manifests from a Jenkins Pipeline when kubectl is configured on the agent.
Jenkins Troubleshooting
6 commandsjava -jar jenkins-cli.jar -s http://localhost:8080/ versionVerify Jenkins server and CLI version information.
java -jar jenkins-cli.jar -s http://localhost:8080/ who-am-iVerify the authenticated Jenkins identity and permissions.
java -jar jenkins-cli.jar -s http://localhost:8080/ list-jobsCheck whether the expected jobs are accessible.
java -jar jenkins-cli.jar -s http://localhost:8080/ list-nodesCheck available Jenkins agents when builds cannot start.
java -jar jenkins-cli.jar -s http://localhost:8080/ list-pluginsInspect installed plugins when Pipeline features are unavailable.
java -jar jenkins-cli.jar -s http://localhost:8080/ console my-job -fFollow live build logs while troubleshooting a failed or hanging build.
Recommended Jenkins Workflow
# Check out source checkout scm # Install dependencies sh 'npm ci' # Run tests sh 'npm test' # Build application sh 'npm run build' # Build container sh 'docker build -t myapp:$BUILD_NUMBER .' # Push container sh 'docker push registry.example.com/myapp:$BUILD_NUMBER' # Deploy sh 'kubectl apply -f k8s/'
DevOpsCommands Tip
Keep Jenkins pipelines in source control with a Jenkinsfile. Store secrets in Jenkins Credentials rather than directly inside Pipeline code, and make build stages small and easy to troubleshoot.