Ant在Docker容器中无法与Jenkins一起使用 [英] Ant not working with Jenkins within a Docker container
问题描述
我想将我的Jenkins CI放在Docker容器中.
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屋!