我正在尝试使用Jenkins和docker容器中的管道插件构建我的项目。我的Jenkinsfile
看起来像这样:
node('docker') {
docker.image('build-node:1').inside {
stage 'scm checkout'
checkout scm
stage 'maven build'
sh "mvn -B clean > mvn.log"
}
}
在Jenkins日志中:
...
Entering stage maven build
Proceeding
[Pipeline] sh
[versioning] Running shell script
+ mvn -B clean
[Pipeline] }
$ docker stop ***
$ docker rm -f ***
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -1
Finished: FAILURE
在mvn.log中,我看到一切正常:
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: X.XXX s
[INFO] Finished at: 2016-XX-XXTXX:XX:XX+XX:XX
[INFO] Final Memory: XXM/XXXM
[INFO] ------------------------------------------------------------------------
错误在哪里或如何确定?
我的Jenkins服务器是docker container form docker hub,它使用docker server作为节点。
新检查:
try {
sh 'mvn clean | tee mvn.log'
} catch (e) {
println "Maven failed : ${e}"
}
输出:
[versioning] Running shell script
+ mvn clean
+ tee mvn.log
[Pipeline] echo
Maven failed : hudson.AbortException: script returned exit code -1
mvn.log:
[INFO] BUILD SUCCESS
答案 0 :(得分:0)
也许试试
sh 'mvn -B clean | tee mvn.log'
这样您就可以在构建日志中看到Maven的输出。或者只是
sh 'mvn -B clean'
如果您不计划将mvn.log
用于任何事情。
答案 1 :(得分:0)
我在1651.3 LTS版本的Jenkins上配置管道,所有工作都很完美。我认为问题是插件或Jenkins的不稳定核心版本的组合。