Tuesday 2 July 2019

Jenkins: Configure Ant project


In this post, I am going to explain how to configure a Jenkins job, that compiles the code located in a github repository using ant build tool.

To demonstrate this application, I am using below ant github repository.

Open Jenkins.
Click on New Item.

Give the project name as ‘ANT_DEMO’, select ‘Freestyle project’ and click on OK button.


Go to General tab,
Update the description as ‘Demo Ant project setup’,

Select check box ‘GitHub project’ and update project url as ‘https://github.com/apache/ant-ivy’.


Go to ‘Source Code Management’ tab.
Select the radio button ‘Git’ and update the repository url as ‘https://github.com/apache/ant-ivy’.



Since this is a public repository, you no need to enter any credentials.

Go to Build section. Select ‘Invoke Ant’.


Add the text ‘jar’ in Targets text field.

Click on Save button to save the changes.

You will be redirected to ‘ANT_DEMO’ project.

Click on Build Now button.

Build will be triggered.


As you see above image, my build is failed. When I see the console output of the build job #1, I seen message like ‘ant.bat' is not recognized as an internal or external command,’.

From the message, it is clear that, I need to install ant in my system.

Ant setup
In Windows
Go to below location and download ant software.
Extract the downloaded zip file, you can able to see below folder structure.

Set ‘ANT_HOME’ property to the ant installation directory.
Add the bin directory of ant to your system path.

Restart Jenkins process.

Rebuild the Jenkins job ‘ANT_DEMO’.


It starts building the project, and build is successful.


Reference


Previous                                                 Next                                                 Home

No comments:

Post a Comment