Learn Jenkins CLI Commands
Contents
Real-Time Jenkins Commands
Jenkins CLI Commands
- Start Jenkins Service Start Jenkins using your system’s service management tool, such as
systemctl start jenkins
. - Stop Jenkins Service Stop the Jenkins service with a command like
systemctl stop jenkins
. - Restart Jenkins Service Restart Jenkins with
systemctl restart jenkins
. - Check Jenkins Status Use
systemctl status jenkins
to check if Jenkins is running. - Access Jenkins Web Interface Open a web browser and go to
http://localhost:8080
.
Jenkins Job Management
- Create a New Job Use the Jenkins UI to create a new job by selecting “New Item”.
- Delete a Job Remove a job through the Jenkins interface by selecting “Delete Project”.
- Configure a Job Edit job settings via the Jenkins dashboard under “Configure”.
- Build a Job Now Trigger a build by clicking “Build Now” on the job page.
- Schedule a Job Set up build schedules in the job configuration using cron syntax.
- Trigger Build Remotely Use a URL with a token to trigger builds remotely:
http://<JENKINS_URL>/job/<JOB_NAME>/build?token=<TOKEN>
. - View Build History Access the build history from the job’s page to review past builds.
- Check Console Output View detailed logs from a build under “Console Output”.
- Archive Build Artifacts Configure post-build actions to save build artifacts.
Jenkins Pipeline Management
- Create a Pipeline Job Set up a new pipeline job from the Jenkins dashboard.
- Configure Pipeline Script Use the pipeline editor to write and configure pipeline scripts.
- Run Pipeline Script Execute the pipeline script by triggering a build.
- View Pipeline Stages Check the stages and steps of a running or completed pipeline build.
- Pause and Resume Pipeline Pause or resume a pipeline job from the Jenkins UI.
Jenkins Plugin Management
- Install a Plugin Go to Manage Jenkins > Manage Plugins > Available, search for a plugin, and install it.
- Update Plugins Check for updates under Manage Jenkins > Manage Plugins > Updates.
- Uninstall a Plugin Remove a plugin through Manage Jenkins > Manage Plugins > Installed.
User and Security Management
- Add a New User Create users through Manage Jenkins > Manage Users > Create User.
- Assign User Roles Manage user roles and permissions using Role-Based Authorization plugins.
Jenkins CLI Commands
- Jenkins CLI Help Get help with the Jenkins CLI:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> help
. - List Jenkins Jobs List all jobs using the Jenkins CLI:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-jobs
. - Build a Job Using CLI Trigger a job build from the command line:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> build <JOB_NAME>
. - Create a New Job Using CLI Create a job with the CLI:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> create-job <JOB_NAME> < config.xml
. - Delete a Job Using CLI Remove a job via CLI:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> delete-job <JOB_NAME>
. - Get Job Configuration Using CLI Retrieve the configuration of a job:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> get-job <JOB_NAME>
. - Set Job Configuration Using CLI Update a job’s configuration:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> update-job <JOB_NAME> < config.xml
. - List All Nodes View all nodes:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-nodes
. - Create a New Node Using CLI Add a new node:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> create-node <NODE_NAME> < config.xml
. - Delete a Node Using CLI Remove a node:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> delete-node <NODE_NAME>
. - Restart Jenkins Using CLI Restart Jenkins:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> restart
.
Troubleshooting Jenkins Commands
Log and System Information
- View System Log Access system logs through Manage Jenkins > System Log.
- Check Jenkins System Information Review system information under Manage Jenkins > System Information.
- View Build Log Check detailed build logs for troubleshooting under “Console Output”.
- Clear Jenkins Cache Manually clear Jenkins cache to resolve issues related to cache corruption.
- Analyze Jenkins Health Use Manage Jenkins > Manage Plugins > Plugin Manager to check for issues.
Jenkins CLI Troubleshooting Commands
- Get Jenkins CLI Help Display help information for Jenkins CLI commands:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> help
. - Check Jenkins Version Determine the Jenkins version:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> version
. - Diagnose Plugin Issues List installed plugins and their versions to identify conflicts:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-plugins
. - View Node Status Check the status of nodes:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> get-node <NODE_NAME>
. - Check Job Status Review the status of a job:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> get-job <JOB_NAME>
. - Trigger a Build Remotely Using CLI Start a build with parameters:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> build <JOB_NAME> -p PARAMETER=value
. - Access Jenkins Environment Variables List environment variables:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> who-am-i
. - Check Jenkins Queue View the build queue to troubleshoot pending builds:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> queue
. - Restart a Node Restart a specific node:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> restart-node <NODE_NAME>
. - Update Jenkins Plugins Update plugins to the latest version:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> install-plugin <PLUGIN_NAME>
. - Remove a Plugin Using CLI Uninstall a plugin via CLI:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> uninstall-plugin <PLUGIN_NAME>
. - Check Plugin Compatibility Verify if plugins are compatible with the Jenkins version:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> plugin-info <PLUGIN_NAME>
. - Access Jenkins System Properties Display system properties for troubleshooting:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> system-properties
. - Trigger a Build with a Parameter Start a build with parameters specified:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> build <JOB_NAME> -p PARAM=value
. - View Active Build Executors Check the status of build executors:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-executors
. - Monitor Jenkins Performance Review performance metrics:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> performance
. - Inspect Jenkins Security Settings Review and modify security settings:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> security
. - Manage Jenkins User Sessions View and manage active user sessions:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> sessions
. - Reconfigure Jenkins Using CLI Apply a new configuration file:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> reconfigure <config.xml>
. - Perform a Safe Restart Restart Jenkins safely to avoid data loss:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> safe-restart
. - Run Jenkins in Debug Mode Start Jenkins in debug mode for more verbose logging:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> debug
. - Update Jenkins Configuration Apply configuration changes:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> update-config <config.xml>
. - Check Jenkins Memory Usage Monitor memory usage to troubleshoot performance issues:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> memory
. - Verify Jenkins Installation Ensure Jenkins is properly installed and functioning:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> verify-installation
. - List All Jenkins Jobs List all jobs to verify their status:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-jobs
. - Get Details of a Specific Job Retrieve detailed information about a specific job:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> get-job <JOB_NAME>
. - Manage Jenkins Queues Monitor and manage build queues:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> queue
. - List Jenkins Nodes Display a list of all Jenkins nodes:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-nodes
. - Update Jenkins System Configuration Apply system configuration changes:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> update-system-config
. - Clear Jenkins Workspace Remove workspace files to troubleshoot build issues:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> clean-workspace
. - Inspect Jenkins Build Status View the status of a specific build:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> build-status <BUILD_NUMBER>
. - Access Jenkins Job Parameters Retrieve parameters for a specific job:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> job-parameters <JOB_NAME>
. - Set Jenkins System Properties Configure system properties for Jenkins:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> set-system-properties
. - List Active Jenkins Executors Display active build executors:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-executors
. - Check Jenkins Plugin Dependencies Verify dependencies for installed plugins:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> plugin-dependencies
. - Update Jenkins Plugins via CLI Install or update plugins with specified versions:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> install-plugin <PLUGIN_NAME>@<VERSION>
. - Check Jenkins User Permissions View permissions assigned to users:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> user-permissions
. - Restart a Specific Node Restart a specific Jenkins node to resolve issues:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> restart-node <NODE_NAME>
. - Inspect Jenkins Security Configuration Review and adjust Jenkins security settings:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> security-config
. - Manage Jenkins Jobs via CLI Create, update, or delete jobs from the command line:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> manage-jobs
. - List All Active Sessions Check all active user sessions in Jenkins:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> active-sessions
. - Perform Jenkins Backup Backup Jenkins configuration and data:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> backup
. - Restore Jenkins from Backup Restore Jenkins using a backup file:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> restore <backup-file>
. - Verify Jenkins Plugin Health Check if installed plugins are functioning correctly:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> plugin-health
. - Update Jenkins Configuration via CLI Apply configuration changes from a file:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> update-config <file>
. - Run Jenkins Health Checks Perform health checks on Jenkins:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> health-checks
. - Inspect Jenkins Build Queues Monitor and manage build queues:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> inspect-queues
. - List Jenkins Global Configurations View global configurations and settings:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> global-config
. - Check Jenkins Node Health Assess the health of Jenkins nodes:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> node-health <NODE_NAME>
. - Inspect Jenkins Job Logs Review job logs for debugging:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> job-logs <JOB_NAME>
. - Perform Jenkins Safe Restart Restart Jenkins in a safe mode:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> safe-restart
. - Update Jenkins Security Settings Apply updates to security settings:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> update-security-settings
. - Manage Jenkins Build Artifacts Handle build artifacts and manage their lifecycle:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> manage-artifacts
. - Check Jenkins Build Times Review build times to identify performance issues:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> build-times
. - Review Jenkins System Logs Access and analyze system logs for troubleshooting:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> system-logs
. - Check Jenkins API Access Verify API access and usage:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> api-access
. - Inspect Jenkins System Health Monitor the overall health of Jenkins:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> system-health
. - Update Jenkins Core Update Jenkins core to the latest version:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> update-core
. - Check Jenkins Queue Length Monitor the length of the build queue:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> queue-length
. - Manage Jenkins Backup Schedule Configure and manage backup schedules:
java -jar jenkins-cli.jar -s http://<JENKINS_URL> backup-schedule
.