0

I am trying to build my project with Jenkins and pipeline plugin in docker container. My Jenkinsfile looks like this:

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

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

In Jenkins 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

In mvn.log I see all is ok:

...
[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] ------------------------------------------------------------------------

Where is an error or how determine it?

My Jenkins server is docker container form docker hub, which using docker server as a node.

New check:

try {
    sh 'mvn clean | tee mvn.log'
} catch (e) {
    println "Maven failed : ${e}"
}

Output:

[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
4

2 回答 2

0

也许尝试

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

这样您就可以在构建日志中看到 Maven 的输出。或者干脆

sh 'mvn -B clean'

如果你不打算使用mvn.log任何东西。

于 2016-06-06T22:24:11.850 回答
0

我在 Jenkins 的 1651.3 LTS 版本上配置了管道,并且一切正常。我认为问题出在插件或 Jenkins 的不稳定核心版本的组合中。

于 2016-06-21T07:48:35.777 回答