如何在 Jenkins Groovy 管道中调用 Ant [英] How to invoke Ant in a Jenkins Groovy Pipeline
问题描述
我创建了一个 Jenkins Pipeline 作业.在这份工作中,我想使用 Ant 进行构建.我已经在 Manage **Jenkins > 中配置了 Ant 变量.全局工具配置**
为Ant1.9.1= D:\path_to_hybris\hybris\bin\platform\apache-ant-1.9.1
.
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
.
在自由式 jenkins 工作中,我知道可以在下面的屏幕截图中指定 build.xml 位置:
In a freestyle jenkins Job, I know that the build.xml location can be specified as in the below screenshot:
但是我无法理解如何在这一点之外指定 ant groovy 脚本,尤其是我们在哪里可以提到 build.xml 文件的路径:
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'
????
????
推荐答案
您可以在 Jenkins 的管道 groovy 脚本中使用 ant 包装器.
you can use ant wrapper in Jenkins`s pipeline groovy script.
withAnt(installation: 'LocalAnt') {
// some block
sh "ant build"
//for windows
bat "ant build"
}
记得在Jenkins全局工具配置"中配置ant工具同名LocalAnt".
Remember to configure the ant tool in the Jenkins "Global Tool Configuration" with the same name "LocalAnt".
这篇关于如何在 Jenkins Groovy 管道中调用 Ant的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!