As we all know Jenkins is a popular CI
Tools and can be integrated with almost all the other popular testing and DevOps
tool.
In this article, we will learn how we can run
our Jenkins job from JAVA Code.
We need to follow the below steps to run Jenkins Job from JAVA Code.
1)
Login into Jenkins with your
admin user id/password and click on id present on the top right of the screen.
2)
Click on Configure then click
on Add New Token option inside API Token.
3)
Click on Generate, One unique
token id will be generated for your id. Copy this token id for your reference.
4)
Now either create or open
existing Jenkins job which we want to execute through our code.
5)
Click on Trigger build remotely
inside Build Triggers and provide the token id generated in step 2.
6)
Click on Apply and save the
Jenkins Job.
7)
Now we need to use the below code.
Please Note in URL we
first need to provide the exact path of Jenkins job followed by
build?token=your token id.
Hi ..im running my program as 'Run as Java application' given all the proper details but getting ....
ReplyJob status is 403
execution ended
please help
Hi Ankur our Jenkins is hosted on cloud so only passing authentication value will work in URL?
Reply222
Reply