Discussion:
Disable standard output from Jenkins pipeline:
Geethalakshmi Ramachandran
2017-02-16 16:23:41 UTC
Permalink
A jenkins pipeline calls an API that returns metrics and prints it in the console output with formatting. However, Jenkins pipeline prints standard output for each command like below: How to disable this or turn it off?

Hide quoted text


[Pipeline] sh

[Rel _pipeline] Running shell script







def pipelineUtil=null

fileLoader.withGit('ssh://***@test:7999/test/test.git',

test,

'..,

'groovy')

{

pUtil = fileLoader.load('src/pipeline/test-utils')

}



pUtil.getTest("TEST")



test-utils.groovy



void getTest(String test) {

stage "Test"

node ('groovy')

{

sh "set +x"

mysh "curl call some api"

mysh 'echo "***********TEST************"'

mysh 'echo "Overall : "'

}

}



def mysh(cmd) {

sh('#!/bin/sh -e\n' + cmd)

}



return this;



Output :

[Pipeline] sh

[Rel _pipeline] Running shell script

***********TEST ************

[Pipeline] sh

[Rel_ pipeline] Running shell script

Overall :
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6188bf7c-8d54-4b40-b9ac-79cc15cd3d2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
David Karr
2017-02-19 17:25:38 UTC
Permalink
On Thu, Feb 16, 2017 at 8:23 AM, Geethalakshmi Ramachandran
Post by Geethalakshmi Ramachandran
A jenkins pipeline calls an API that returns metrics and prints it in the console output with formatting. However, Jenkins pipeline prints standard output for each command like below: How to disable this or turn it off?
If you want to control how or whether stdout is emitted from a "sh"
step, instead of calling it like this:
----------
sh "command line"
---------

Do:
----
sh returnStdout: true; script: "command line"
----

I suppose you could set that to "false" also,but I've never done that.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VqtAd7a_u6Nac2xO%2BZhitVy3wDeaQ0eP65-0a-YdUMQFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Jean-Marc Taillant
2018-11-16 08:46:16 UTC
Permalink
In fact, from Jenkins doc:

returnStdout

If checked, standard output from the task is returned as the step value as
a String, rather than being printed to the build log. (Standard error, if
any, will still be printed to the log.) You will often want to call .trim() on
the result to strip off a trailing newline.
Post by David Karr
On Thu, Feb 16, 2017 at 8:23 AM, Geethalakshmi Ramachandran
Post by Geethalakshmi Ramachandran
A jenkins pipeline calls an API that returns metrics and prints it in
the console output with formatting. However, Jenkins pipeline prints
standard output for each command like below: How to disable this or turn it
off?
If you want to control how or whether stdout is emitted from a "sh"
----------
sh "command line"
---------
----
sh returnStdout: true; script: "command line"
----
I suppose you could set that to "false" also,but I've never done that.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a70604ff-d115-42cd-a953-bdd164e1a5d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...