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

I am writing a pipeline job in Jenkins that shows the output console of a downstream job on the output of the pipeline console. The work still works, but the result is very difficult to read because of all the echo lines added to the output by the pipelined task itself.

Started by user john.doe@cdf.com [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 in either Groovy or Jenkins so that I can suppress all unnecessary β€œechoes” to make the console output more readable?

+7
source share
3 answers

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

+1
source

Do you need to do this through Jenkins? If not, you can disable it directly from the console (provided that you get output on the linux console):

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

which would leave only:

 Started by user john.doe@cdf.com Running on swqa-pr-prod-slave-1 in /srv/jenkins-slave/workspace/UUT Automated Regression - 1.20 ///////////////////////////////////////////////// Start Execution ///////////////////////////////////////////////// 

UPDATE: if you want this "live" to match your output and translate it into a string with grep buffering:

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

One partial workaround specifically for your example

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

the block you are trying to reach is to use one echo call on multi-line

'''triple single quoted string''' (which may include interpolated strings).

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

Triple single quotes are multi-line. You can distribute the contents of a string along the boundaries of a string without having to split the string into several parts without line breaks or line breaks:

0
source

All Articles