准备工作
- 下载地址:https://ant.apache.org/bindownload.cgi
- 复制下载地址
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/f63b708b3144444e9673f96f43f0f49e.png)
- 将ant包下载到本地/tools/目录下,如果用wget下载慢,可用迅雷下载
wget https://dlcdn.apache.org//ant/binaries/apache-ant-1.9.16-bin.tar.gz --no-check-certificate
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/fdee2b57416c4bb8b2c67eb2d689a5ef.png)
安装和配置环境变量
tar -zxvf apache-ant-1.9.16-bin.tar.gz -C /usr/local/
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/5de039917e9647dabf972bdf1ad8f25e.png)
- 找到ant的安装目录/usr/local/apache-ant-1.9.16
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/cbe1ffecca624ccfb2354bcd58109a6d.png - 编辑/etc/profile配置环境变量(这是centos)source该文件
vi /etc/profile
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/861aa72c84264ffcb0db449aa3558968.png)
source /etc/profile
- 查看ant是否正确安装 ant --version
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/776319919a894f0087eb98bff2a720db.png)
jenkins配置
- 进入“系统管理” --> “全局工具配置” --> “Ant 安装” (若没有ant则先安装插件)
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/8f4e0e56f7454c4790077bf57d7a4234.png)
- 验证是否配置成功
string buildShell = "$BUILD_SHELL"
pipeline{
agent {
node {label "$CI_NODE"}
}
stages{
stage("mvn build"){
steps{
script{
mvnHome = tool "MVN"
sh "$mvnHome/bin/mvn ${buildShell}"
}
}
}
stage("ant build"){
steps{
script{
antHome = tool "ANT"
sh "$antHome/bin/ant ${buildShell}"
}
}
}
}
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/5551681e43304e21bc134e1c433b9995.png)