Ant not working with Jenkins within a Docker container

落爺英雄遲暮 提交于 2020-01-05 04:51:24

问题


I want to have my Jenkins CI in a Docker container.

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 is started okay, I configure the job for the project using Ant as build tool.

When I run the job, Jenkins throws the following error regarding to Ant (regardless the configured build target):

ERROR: command execution failed.Maybe you need to configure the job to choose one of your Ant installations?

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

What am I doing wrong?


回答1:


As @izzekil has pointed, Ant was not installed inside the container, but only in the host machine.

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

And then:

sudo docker exec <container_id> apt-get update
sudo docker exec <container_id> apt-get install ant -y


来源:https://stackoverflow.com/questions/38688912/ant-not-working-with-jenkins-within-a-docker-container

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!