This post talks about how to build a jenkins job using simple java program that is pulled from Github.
Technology Stack :
1) Jenkins
2) GitHub
3) Git Client
1) Create a new repository in GitHub (Assuming you have a GitHub account)
2) Give repository a name : Say > JavaHelloWorld
3) Observe few commands at newly created repository on below image.
We use add, commit, push commands to send a file to GitHub
4) (Assuming git client is installed)
Create a folder in D drive say : D:\JavaHelloWorld and put the JavaHelloWorld.java program and a batch file say run.batch in which we write javac and java commands to execute the program
Now do gitbash to add, commit and push the 2 files.
git add JavaHelloWorld.java
git commit -m "Commiting Java Hello World Program - first"
git push -u origin master
repeat the same for run.sh file (this is added after pushing the JavaHelloWorld file)
5) Start Jenkins in your environment and build a new project as shown in below
7) In Jenkins Source Code Management tab provide the gitURL
https://github.com/sadakar/JavaHelloWorld.git and provide credentails of your github as shown below
9) Now, click on build project as shown below
10) Navigate to see where the pulled git code stored internally in the OS drive.
Technology Stack :
1) Jenkins
2) GitHub
3) Git Client
1) Create a new repository in GitHub (Assuming you have a GitHub account)
2) Give repository a name : Say > JavaHelloWorld
3) Observe few commands at newly created repository on below image.
We use add, commit, push commands to send a file to GitHub
4) (Assuming git client is installed)
Create a folder in D drive say : D:\JavaHelloWorld and put the JavaHelloWorld.java program and a batch file say run.batch in which we write javac and java commands to execute the program
Now do gitbash to add, commit and push the 2 files.
git add JavaHelloWorld.java
git commit -m "Commiting Java Hello World Program - first"
git push -u origin master
repeat the same for run.sh file (this is added after pushing the JavaHelloWorld file)
5) Start Jenkins in your environment and build a new project as shown in below
6) Copy/Clone the URL of github
7) In Jenkins Source Code Management tab provide the gitURL
https://github.com/sadakar/JavaHelloWorld.git and provide credentails of your github as shown below
8) In Build Triggers tab provide the batch code to run the example.
In this example, the code is written in run.bat file to execute the hello world program
9) Now, click on build project as shown below
9) See the execution log on Console output.
10) Navigate to see where the pulled git code stored internally in the OS drive.
Thanks for providing your information! Keep update and share
ReplyDeleteDocker Training
Docker Online Training
Kubernetes Online Training
Docker and Kubernetes Training
Graet article with very unique content.
ReplyDeletekeep sharing it more concepts.
Thank you....
Power BI Training
Awesome article, it was extraordinarily helpful! I'm just getting started and I'm getting better at it!
ReplyDeleteMachine Learning Course in Bangalore
Artificial Intelligence Training in Bangalore