2016-06-06 57 views
0

我想在碼頭集裝箱中用Jenkins和管道插件建立我的項目。我Jenkinsfile看起來是這樣的:jenkins 2.7管道建在碼頭集裝箱

node('docker') { 
    docker.image('build-node:1').inside { 
     stage 'scm checkout' 
     checkout scm 

     stage 'maven build' 
     sh "mvn -B clean > mvn.log" 
    } 
} 

在詹金斯日誌:

... 
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容器表單docker hub,它使用docker服務器作爲節點。

新的檢查:

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

https://issues.jenkins-ci.org/browse/JENKINS-35430 – burtsevyg

回答

0

我在1651.3 LTS版本的Jenkins上配置管道,所有工作都很完美。我認爲問題在於插件或Jenkins的不穩定核心版本的組合。

0

也許嘗試

sh 'mvn -B clean | tee mvn.log' 

,以便您可以在構建日誌中看到來自Maven的輸出。或者乾脆

sh 'mvn -B clean' 

如果你不打算使用mvn.log任何東西反正。

+0

命令sh'mvn -B clean'在Jenkins日誌中沒有日誌,與問題相同。 – burtsevyg

+0

我添加「> mvn.log」來構建命令以瞭解發生了什麼。 – burtsevyg

+0

詹金斯2.8同樣的問題 – burtsevyg