Learn Jenkins CLI Commands

Real-Time Jenkins Commands

Jenkins CLI Commands

  1. Start Jenkins Service Start Jenkins using your system’s service management tool, such as systemctl start jenkins.
  2. Stop Jenkins Service Stop the Jenkins service with a command like systemctl stop jenkins.
  3. Restart Jenkins Service Restart Jenkins with systemctl restart jenkins.
  4. Check Jenkins Status Use systemctl status jenkins to check if Jenkins is running.
  5. Access Jenkins Web Interface Open a web browser and go to http://localhost:8080.

Jenkins Job Management

  1. Create a New Job Use the Jenkins UI to create a new job by selecting “New Item”.
  2. Delete a Job Remove a job through the Jenkins interface by selecting “Delete Project”.
  3. Configure a Job Edit job settings via the Jenkins dashboard under “Configure”.
  4. Build a Job Now Trigger a build by clicking “Build Now” on the job page.
  5. Schedule a Job Set up build schedules in the job configuration using cron syntax.
  6. Trigger Build Remotely Use a URL with a token to trigger builds remotely: http://<JENKINS_URL>/job/<JOB_NAME>/build?token=<TOKEN>.
  7. View Build History Access the build history from the job’s page to review past builds.
  8. Check Console Output View detailed logs from a build under “Console Output”.
  9. Archive Build Artifacts Configure post-build actions to save build artifacts.

Jenkins Pipeline Management

  1. Create a Pipeline Job Set up a new pipeline job from the Jenkins dashboard.
  2. Configure Pipeline Script Use the pipeline editor to write and configure pipeline scripts.
  3. Run Pipeline Script Execute the pipeline script by triggering a build.
  4. View Pipeline Stages Check the stages and steps of a running or completed pipeline build.
  5. Pause and Resume Pipeline Pause or resume a pipeline job from the Jenkins UI.

Jenkins Plugin Management

  1. Install a Plugin Go to Manage Jenkins > Manage Plugins > Available, search for a plugin, and install it.
  2. Update Plugins Check for updates under Manage Jenkins > Manage Plugins > Updates.
  3. Uninstall a Plugin Remove a plugin through Manage Jenkins > Manage Plugins > Installed.

User and Security Management

  1. Add a New User Create users through Manage Jenkins > Manage Users > Create User.
  2. Assign User Roles Manage user roles and permissions using Role-Based Authorization plugins.

Jenkins CLI Commands

  1. Jenkins CLI Help Get help with the Jenkins CLI: java -jar jenkins-cli.jar -s http://<JENKINS_URL> help.
  2. List Jenkins Jobs List all jobs using the Jenkins CLI: java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-jobs.
  3. 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>.
  4. 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.
  5. Delete a Job Using CLI Remove a job via CLI: java -jar jenkins-cli.jar -s http://<JENKINS_URL> delete-job <JOB_NAME>.
  6. Get Job Configuration Using CLI Retrieve the configuration of a job: java -jar jenkins-cli.jar -s http://<JENKINS_URL> get-job <JOB_NAME>.
  7. 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.
  8. List All Nodes View all nodes: java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-nodes.
  9. 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.
  10. Delete a Node Using CLI Remove a node: java -jar jenkins-cli.jar -s http://<JENKINS_URL> delete-node <NODE_NAME>.
  11. Restart Jenkins Using CLI Restart Jenkins: java -jar jenkins-cli.jar -s http://<JENKINS_URL> restart.

Troubleshooting Jenkins Commands

Log and System Information

  1. View System Log Access system logs through Manage Jenkins > System Log.
  2. Check Jenkins System Information Review system information under Manage Jenkins > System Information.
  3. View Build Log Check detailed build logs for troubleshooting under “Console Output”.
  4. Clear Jenkins Cache Manually clear Jenkins cache to resolve issues related to cache corruption.
  5. Analyze Jenkins Health Use Manage Jenkins > Manage Plugins > Plugin Manager to check for issues.

Jenkins CLI Troubleshooting Commands

  1. Get Jenkins CLI Help Display help information for Jenkins CLI commands: java -jar jenkins-cli.jar -s http://<JENKINS_URL> help.
  2. Check Jenkins Version Determine the Jenkins version: java -jar jenkins-cli.jar -s http://<JENKINS_URL> version.
  3. Diagnose Plugin Issues List installed plugins and their versions to identify conflicts: java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-plugins.
  4. View Node Status Check the status of nodes: java -jar jenkins-cli.jar -s http://<JENKINS_URL> get-node <NODE_NAME>.
  5. Check Job Status Review the status of a job: java -jar jenkins-cli.jar -s http://<JENKINS_URL> get-job <JOB_NAME>.
  6. 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.
  7. Access Jenkins Environment Variables List environment variables: java -jar jenkins-cli.jar -s http://<JENKINS_URL> who-am-i.
  8. Check Jenkins Queue View the build queue to troubleshoot pending builds: java -jar jenkins-cli.jar -s http://<JENKINS_URL> queue.
  9. Restart a Node Restart a specific node: java -jar jenkins-cli.jar -s http://<JENKINS_URL> restart-node <NODE_NAME>.
  10. Update Jenkins Plugins Update plugins to the latest version: java -jar jenkins-cli.jar -s http://<JENKINS_URL> install-plugin <PLUGIN_NAME>.
  11. Remove a Plugin Using CLI Uninstall a plugin via CLI: java -jar jenkins-cli.jar -s http://<JENKINS_URL> uninstall-plugin <PLUGIN_NAME>.
  12. 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>.
  13. Access Jenkins System Properties Display system properties for troubleshooting: java -jar jenkins-cli.jar -s http://<JENKINS_URL> system-properties.
  14. 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.
  15. View Active Build Executors Check the status of build executors: java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-executors.
  16. Monitor Jenkins Performance Review performance metrics: java -jar jenkins-cli.jar -s http://<JENKINS_URL> performance.
  17. Inspect Jenkins Security Settings Review and modify security settings: java -jar jenkins-cli.jar -s http://<JENKINS_URL> security.
  18. Manage Jenkins User Sessions View and manage active user sessions: java -jar jenkins-cli.jar -s http://<JENKINS_URL> sessions.
  19. Reconfigure Jenkins Using CLI Apply a new configuration file: java -jar jenkins-cli.jar -s http://<JENKINS_URL> reconfigure <config.xml>.
  20. Perform a Safe Restart Restart Jenkins safely to avoid data loss: java -jar jenkins-cli.jar -s http://<JENKINS_URL> safe-restart.
  21. Run Jenkins in Debug Mode Start Jenkins in debug mode for more verbose logging: java -jar jenkins-cli.jar -s http://<JENKINS_URL> debug.
  22. Update Jenkins Configuration Apply configuration changes: java -jar jenkins-cli.jar -s http://<JENKINS_URL> update-config <config.xml>.
  23. Check Jenkins Memory Usage Monitor memory usage to troubleshoot performance issues: java -jar jenkins-cli.jar -s http://<JENKINS_URL> memory.
  24. Verify Jenkins Installation Ensure Jenkins is properly installed and functioning: java -jar jenkins-cli.jar -s http://<JENKINS_URL> verify-installation.
  25. List All Jenkins Jobs List all jobs to verify their status: java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-jobs.
  26. 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>.
  27. Manage Jenkins Queues Monitor and manage build queues: java -jar jenkins-cli.jar -s http://<JENKINS_URL> queue.
  28. List Jenkins Nodes Display a list of all Jenkins nodes: java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-nodes.
  29. Update Jenkins System Configuration Apply system configuration changes: java -jar jenkins-cli.jar -s http://<JENKINS_URL> update-system-config.
  30. Clear Jenkins Workspace Remove workspace files to troubleshoot build issues: java -jar jenkins-cli.jar -s http://<JENKINS_URL> clean-workspace.
  31. Inspect Jenkins Build Status View the status of a specific build: java -jar jenkins-cli.jar -s http://<JENKINS_URL> build-status <BUILD_NUMBER>.
  32. Access Jenkins Job Parameters Retrieve parameters for a specific job: java -jar jenkins-cli.jar -s http://<JENKINS_URL> job-parameters <JOB_NAME>.
  33. Set Jenkins System Properties Configure system properties for Jenkins: java -jar jenkins-cli.jar -s http://<JENKINS_URL> set-system-properties.
  34. List Active Jenkins Executors Display active build executors: java -jar jenkins-cli.jar -s http://<JENKINS_URL> list-executors.
  35. Check Jenkins Plugin Dependencies Verify dependencies for installed plugins: java -jar jenkins-cli.jar -s http://<JENKINS_URL> plugin-dependencies.
  36. 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>.
  37. Check Jenkins User Permissions View permissions assigned to users: java -jar jenkins-cli.jar -s http://<JENKINS_URL> user-permissions.
  38. 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>.
  39. Inspect Jenkins Security Configuration Review and adjust Jenkins security settings: java -jar jenkins-cli.jar -s http://<JENKINS_URL> security-config.
  40. 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.
  41. List All Active Sessions Check all active user sessions in Jenkins: java -jar jenkins-cli.jar -s http://<JENKINS_URL> active-sessions.
  42. Perform Jenkins Backup Backup Jenkins configuration and data: java -jar jenkins-cli.jar -s http://<JENKINS_URL> backup.
  43. Restore Jenkins from Backup Restore Jenkins using a backup file: java -jar jenkins-cli.jar -s http://<JENKINS_URL> restore <backup-file>.
  44. Verify Jenkins Plugin Health Check if installed plugins are functioning correctly: java -jar jenkins-cli.jar -s http://<JENKINS_URL> plugin-health.
  45. Update Jenkins Configuration via CLI Apply configuration changes from a file: java -jar jenkins-cli.jar -s http://<JENKINS_URL> update-config <file>.
  46. Run Jenkins Health Checks Perform health checks on Jenkins: java -jar jenkins-cli.jar -s http://<JENKINS_URL> health-checks.
  47. Inspect Jenkins Build Queues Monitor and manage build queues: java -jar jenkins-cli.jar -s http://<JENKINS_URL> inspect-queues.
  48. List Jenkins Global Configurations View global configurations and settings: java -jar jenkins-cli.jar -s http://<JENKINS_URL> global-config.
  49. Check Jenkins Node Health Assess the health of Jenkins nodes: java -jar jenkins-cli.jar -s http://<JENKINS_URL> node-health <NODE_NAME>.
  50. Inspect Jenkins Job Logs Review job logs for debugging: java -jar jenkins-cli.jar -s http://<JENKINS_URL> job-logs <JOB_NAME>.
  51. Perform Jenkins Safe Restart Restart Jenkins in a safe mode: java -jar jenkins-cli.jar -s http://<JENKINS_URL> safe-restart.
  52. Update Jenkins Security Settings Apply updates to security settings: java -jar jenkins-cli.jar -s http://<JENKINS_URL> update-security-settings.
  53. Manage Jenkins Build Artifacts Handle build artifacts and manage their lifecycle: java -jar jenkins-cli.jar -s http://<JENKINS_URL> manage-artifacts.
  54. Check Jenkins Build Times Review build times to identify performance issues: java -jar jenkins-cli.jar -s http://<JENKINS_URL> build-times.
  55. Review Jenkins System Logs Access and analyze system logs for troubleshooting: java -jar jenkins-cli.jar -s http://<JENKINS_URL> system-logs.
  56. Check Jenkins API Access Verify API access and usage: java -jar jenkins-cli.jar -s http://<JENKINS_URL> api-access.
  57. Inspect Jenkins System Health Monitor the overall health of Jenkins: java -jar jenkins-cli.jar -s http://<JENKINS_URL> system-health.
  58. Update Jenkins Core Update Jenkins core to the latest version: java -jar jenkins-cli.jar -s http://<JENKINS_URL> update-core.
  59. Check Jenkins Queue Length Monitor the length of the build queue: java -jar jenkins-cli.jar -s http://<JENKINS_URL> queue-length.
  60. Manage Jenkins Backup Schedule Configure and manage backup schedules: java -jar jenkins-cli.jar -s http://<JENKINS_URL> backup-schedule.