Miguel Leal Rosales
Miguel Leal Rosales

Reputation: 91

How to suppress source script lines echo in jenkins pipeline console output?

I am writing a pipeline job in Jenkins which shows the output console of a downstream job in the pipeline console output. The job is working so far but the output is really hard to read due to all the echo lines added to the output by the pipeline job itself.

Started by user [email protected]
[Pipeline] Allocate node : Start
Running on swqa-pr-prod-slave-1 in /srv/jenkins-slave/workspace/UUT Automated Regression - 1.20
[Pipeline] node {
[Pipeline] echo

[Pipeline] echo
/////////////////////////////////////////////////
[Pipeline] echo
                Start Execution                  
[Pipeline] echo
/////////////////////////////////////////////////
[Pipeline] echo

[Pipeline] echo

[Pipeline] [monitor] echo
[monitor] [EnvInject] - Loading node environment variables.
[Pipeline] [monitor] echo
[monitor] Building remotely on swqa-pr-prod-slave-1 (pr-prod-linux-slaves) in workspace /srv/jenkins-slave/workspace/Process Map Components Lock Down - 1.00
[Pipeline] [monitor] echo
[monitor] [EnvInject] - Injecting environment variables from a build step.
[Pipeline] [monitor] echo
[monitor] [EnvInject] - Injecting as environment variables the properties content 
[Pipeline] [monitor] echo
[monitor] componentsLockDownScript=RegressionComponentsLockDown.py
[Pipeline] [monitor] echo
[monitor] modifyProcessMapXmlScript=ModifyXmlDom-1.20.py
[Pipeline] [monitor] echo
[monitor] uutAndNodePropertiesFile=DL380G8PR2-NodeData-(203).properties
[Pipeline] [monitor] echo
[monitor] 
[Pipeline] [monitor] echo
[monitor] [EnvInject] - Variables injected successfully.

Is there an option, configuration, command or anything in the pipeline plugin or in Groovy or in Jenkins to allow me suppress all the extra "echoing" to make the console output more readable?

Upvotes: 9

Views: 6734

Answers (3)

TT--
TT--

Reputation: 3195

One partial workaround specifically for your example of the

/////////////////////////////////////////////////
                Start Execution                  
/////////////////////////////////////////////////

block that you're trying to achieve is to use a single echo call on a multi-line

'''triple single quoted string''' (which could include interpolated strings as well).

From http://docs.groovy-lang.org/latest/html/documentation/#_triple_single_quoted_string,

Triple single quoted strings are multiline. You can span the content of the string across line boundaries without the need to split the string in several pieces, without contatenation or newline escape characters:

Upvotes: 0

user3837712
user3837712

Reputation:

Do you need to do it via jenkins? If not you could grep it out directly from console (assuming you get the output on a linux console):

cat YOUR_EXAMPLE_OUTPUT.txt | grep -v '\[Pipeline\]\|\[monitor\]\|^$' 

that would only leave out:

Started by user [email protected]
Running on swqa-pr-prod-slave-1 in /srv/jenkins-slave/workspace/UUT Automated Regression - 1.20

/////////////////////////////////////////////////
                Start Execution                  
/////////////////////////////////////////////////

UPDATE: if you want it "live" follow your output and pipe it into a line buffered grep:

tail -f YOUR_EXAMPLE_OUTPUT.txt | grep -v '\[Pipeline\]\|\[monitor\]\|^$' --line-buffered

Upvotes: -2

Jesse Glick
Jesse Glick

Reputation: 25451

What you are really looking for is JENKINS-26124. Apparently you have some kind of workaround for this, but there is a flaw in its implementation, which we cannot see in the question.

Upvotes: 2

Related Questions