I am changing my Freestyle Jenkins job configuration to Pipeline. I need to Invoke Ant to perform LogPublisherTask and ArtifactFilePublisherTask. How is it performed using Groovy scripting?
Asked
Active
Viewed 1.5k times
1 Answers
5
You invoke ant just like you do it with maven (take a look at examples https://jenkins.io/doc/pipeline/jenkinsfile/):
node ('linux'){
stage 'Build and Test'
env.PATH = "${tool 'Ant'}/bin:${env.PATH}"
checkout scm
sh 'ant build'
}
The tasks themselves should be configured in the build.xml
.

Krzysztof Krasoń
- 26,515
- 16
- 89
- 115
-
3If you need this on a window system, replace **sh** with **bat** – carl verbiest Aug 21 '16 at 16:16
-
1And remember to configure the ant tool in the jenkins "Global Tool Configuration" with the same name. – PhoneixS Dec 16 '16 at 11:04
-
With regard to location of ant, this seems a little easier on the eyes: `withAnt(installation: 'ant-newest', jdk: 'jdk8') { // some block }` – LOAS Sep 08 '17 at 09:55