Jenkins Pipeline plugin seemingly skipping commands

17 views
Skip to first unread message

lionel...@gmail.com

unread,
Nov 25, 2016, 7:10:32 AM11/25/16
to Jenkins Users
I have a Jenkins Pipeline plugin script that looks like this:

stage("check out project") {
    shell "pwd"
    echo "test 1"
    git credentialsId: "user", url: "http://url/project"
    echo "test 2"
    shell "git --version"
    echo "test 3"
}


The output of the build is then this:

[Pipeline] stage
[Pipeline] { (check out project)
[Pipeline] echo
test 1
[Pipeline] echo
test 2
[Pipeline] echo
test 3
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS


Judging from the output and from the build time only the echo commands are executed. All other commands are ignored. No error seems to occur.

How can I get all commands to be executed?

jer...@bodycad.com

unread,
Nov 25, 2016, 11:22:37 AM11/25/16
to Jenkins Users
They probably are all executed, just the output is not redirect (yeah IO pipe into pipeline are not so funny so far). You can use the redirect stdout

The good
println(shell(['returnStdout': true, 'script': "git --version" ]));

The bad
This doesn't split std::out and std::cerr either, so you are on your own to split and parse the whole thing.

The ugly
You cannot return both the return value ('returnStatus': true) and the stdout at the same time! So you are totaly out of luck if you need both.


Reply all
Reply to author
Forward
0 new messages