Ant 不能在 Docker 容器中与 Jenkins 一起工作 [英] Ant not working with Jenkins within a Docker container
问题描述
我想在 Docker 容器中使用我的 Jenkins CI.
I want to have my Jenkins CI in a Docker container.
我已经拉取了 Jenkins Docker 镜像并启动它遵循文档::>
I've pulled the Jenkins Docker image and started it following the documentation:
sudo docker run -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home jenkins
Jenkins 启动正常,我使用 Ant 作为构建工具为项目配置作业.
Jenkins is started okay, I configure the job for the project using Ant as build tool.
当我运行作业时,Jenkins 抛出以下关于 Ant 的错误(不管配置的构建目标):
When I run the job, Jenkins throws the following error regarding to Ant (regardless the configured build target):
错误:命令执行失败.也许您需要将作业配置为选择您的 Ant 安装之一?
ERROR: command execution failed.Maybe you need to configure the job to choose one of your Ant installations?
但是,如果我转到构建的工作区目录 (/var/jenkins_home/workspace/my_job/
) 并执行相同的目标,则不会出错:
But, if I go to the workspace directory of the build (/var/jenkins_home/workspace/my_job/
) and execute the same target, I get no error:
ant clean
我做错了什么?
推荐答案
正如@izzekil 所指出的,Ant 没有安装在容器内,而只是安装在主机中.
As @izzekil has pointed, Ant was not installed inside the container, but only in the host machine.
在容器中安装 Ant 就足够了(以 root
用户运行):
It has been enough to install Ant in the container (running with root
user):
sudo docker run -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -u root jenkins
然后:
sudo docker exec <container_id> apt-get update
sudo docker exec <container_id> apt-get install ant -y
这篇关于Ant 不能在 Docker 容器中与 Jenkins 一起工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!