Tuesday 2 July 2019

Jenkins: My First Job


In this post, I am going to show you how to create a job in Jenkins.

Open Jenkins.


You can create a new job, either clicking on ‘create new jobs’ hyperlink (or) by clicking on ‘New Item’ button. Click on either of them, you will be redirected to below page.


Enter job name as ‘HelloWorld’.


Select Freestyle project. Click on OK button.

You will be redirected to form configuration page.


Click on Build tab. Under ‘Add build step’ drop down, select Execute shell option.


It opens below window.



Add following statement in the Command box.

echo "Hello Wolrd"

Click on ‘Apply’ button.

Click on Save button.

You will be redirected to ‘HelloWorld’ job.



Click on ‘Build Now’ button to trigger the job execution.


After some time (5 seconds), I seen my HelloWorld’ job is failed.


Click on the job #1.



Click on ‘Console Output’ button to see why the job is failed.


I see below error messages.

java.io.IOException: CreateProcess error=2, The system cannot find the file specified
         at java.lang.ProcessImpl.create(Native Method)
         at java.lang.ProcessImpl.<init>(Unknown Source)
         at java.lang.ProcessImpl.start(Unknown Source)

This happens if you have specified your Windows command as "Execute shell" rather than "Execute Windows batch command".

How to fix the problem?
It is very simple.

Go to HelloWorld job.


Click on Configure button.


Go to Build tab, click on Cancel button to remove shell job.

Add build step -> Execute Windows batch command.


Type echo "Hello World" and save.
Retrigger the build.



You can able to see build is successful.
Click on the build #2.


Go to Console Output, you can able to see ‘Hello World’ message in the console. That’s it…You are done with your first Jenkins Job.


Previous                                                 Next                                                 Home

No comments:

Post a Comment