我尝试在docker容器中构建我的项目,图像如下所示:
FROM maven:3.3.9-jdk-8
WORKDIR mvnBuildDir
ENTRYPOINT ["mvn"]
如果我像下面那样运行我的容器,一切正常.
docker run -v /home/user/Worspace/myMavenProject:/mvnBuildDir myMaven3 clean package
但如果我在我的Jenkinsfile中尝试这个,我得到一个错误,它告诉我什么.
Jenkinsfile:
//...
def maven = docker.image("myMaven3");
maven.inside("-v ${workdir}:/mvnBuildDir"){
stage "build and test"
sh "mvn clean install"
}
//..
错误:
[Pipeline] {
[Pipeline] stage (build and test)
Entering stage build and test
Proceeding
[Pipeline] sh
[master] Running shell script
+ mvn clean install -s mvnSettings.xml
[Pipeline] }
$docker stop 1fc920c00b46a1038b0f39e2adc6e67f702d48ccf10d3e0bb3514d1cee3a795b
$docker rm -f 1fc920c00b46a1038b0f39e2adc6e67f702d48ccf10d3e0bb3514d1cee3a795b
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // withDockerRegistry
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -1
Finished: FAILURE
有没有人知道这里的问题是什么,或者有任何其他解决方案如何在docker容器内构建我的项目?
我的整个工作区都映射到容器内部,所以问题不在于我认为没有找到pom或其他东西.如果我运行’mvn –version’,我得到了正确的输出.
谢谢到目前为止.
最佳答案
原文链接:https://www.f2er.com/docker/435970.html