Working commands for Login
# Method 1 - Login to Jenkins using CLI and Username and Password
$ java -jar jenkins-cli.jar -s http://13.235.81.87:8080/ -auth rajesh:1190c7e6cb8e3b65515f8495966814ad58 who-am-i
$ java -jar jenkins-cli.jar -s http://13.235.81.87:8080/ -auth rajesh:1190c7e6cb8e3b65515f8495966814ad58 delete-job test
##Command to know the status of Build?
$ curl http://myjenkins/job/myjob/lastBuild/api/json | grep --color result\":null
$ echo $?
##Trigger a Jenkins Job without authentication
$ wget http://yourserver/job/MyJobname/build?delay=0sec
$ wget -O - $HUDSON_URL/job/JOBNAME/build
$ curl http://jenkins:8080/job/my%20job/build
##Trigger a Jenkins Job with authentication
$ curl --user dbacher:$MY_API_TOKEN http://jenkins:8080/job/my%20job/build
$ curl --user <your_jenkins_username>:<your_jenkins_API_key>http://<jenkins_server_url>/job/<your_jenkins_job_name>/build
##Running commands against a secure Jenkins (basic auth or ssh keys)
$ java -jar jenkins-cli.jar -s http://myjenkins help --username me --password mypassword
$ java -jar jenkins-cli.jar -s http://myjenkins help -i ~/.ssh/id_rsa
##Triggering a job build against a secure Jenkins (avoiding a 1.5 year old open bug!)
$ java -jar jenkins-cli.jar -s http://myjenkins build 'My Awesome Jenkins Job' -i ~/.ssh/id_rsa
$ java -jar jenkins-cli.jar -s http://myjenkins build 'My Awesome Jenkins Job' -i ~/.ssh/id_rsa -s -v
##Passing parameters when triggering a job build
$ java -jar jenkins-cli.jar -s http://myjenkins build 'Deploy XYZ App' -i ~/.ssh/id_rsa -s -v -p target_env=api.cloudfoundry.com -p branch=master
How to get your_jenkins_API_key?
- Login to your Jenkins.
- Click on the username in the top right.
- Click on Configure.
- Click on ‘Show API Token’ button.
- You got it.
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-1
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-2
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-3
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-4
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-5
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-6
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-7
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-8
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-9
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-10
Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-11
Latest posts by Rajesh Kumar (see all)
- Implementing Managed IT Services: A Step-by-Step Guide - August 30, 2024
- DevOps Foundation Certification - August 29, 2024
- SRE Foundation Certification - August 29, 2024