Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to invoke Ant in a Jenkins Groovy Pipeline

I have created a Jenkins Pipeline job. In this job I want to do the build using Ant. I have configured the Ant variable in Manage **Jenkins > Global Tool Configuration** as Ant1.9.1= D:\path_to_hybris\hybris\bin\platform\apache-ant-1.9.1.

In a freestyle jenkins Job, I know that the build.xml location can be specified as in the below screenshot: enter image description here

but I am unable to understand how to specify the ant groovy script beyond this point, especially where can we mention the path to build.xml file:

def antHome = tool 'Ant1.9.1'
????
????
like image 670
user5917011 Avatar asked Dec 29 '16 18:12

user5917011


People also ask

How do you invoke an Ant in Jenkins pipeline job using Groovy script?

you can use ant wrapper in Jenkins`s pipeline groovy script. Remember to configure the ant tool in the Jenkins "Global Tool Configuration" with the same name "LocalAnt". for the sh "ant build" do I need to put the path to the build xml file or will simply typing `"ant build" work?

How do I run an Ant in Jenkins?

Just select install automatically and choose the appropriate Add Installer option whether you want to extract from zip or install from Apache. Now, Ant is integrated with Jenkins. You can use Ant in the build process. While configuring a job, in the build option select invoke Ant and choose the Ant version.

Does Jenkins support Ant?

Learn how to automate Jenkins continuous integration projects with Apache Ant, a popular build tool for developing software. Jenkins integrates with multiple build tools such as Maven, Gradle, and Ant.


1 Answers

you can use ant wrapper in Jenkins`s pipeline groovy script.

withAnt(installation: 'LocalAnt') {
// some block
   sh "ant build"
//for windows 
   bat "ant build"
}

Remember to configure the ant tool in the Jenkins "Global Tool Configuration" with the same name "LocalAnt".

like image 76
Khalid Bin Huda Avatar answered Sep 17 '22 11:09

Khalid Bin Huda