When creating Jenkins pipelines or libraries which should be used in a pipeline it's often hard to debug code with the logging options provided. At the moment I'm logging with this:
node {
...
sh "echo ${thingtoshow}"
}
The downside is that this it's not very powerful when it comes to Groovy/Java specific details - e.g. it wouldn't allow me to dump the contents of objects right away
It creates a mess in the actual logs:
[Pipeline] sh
[workspace] Running shell script
+ echo 'things'
things
So how could I write logs to just get a single line of log output within the Jenkins console?
Edit: Even though the code example doesn't show it, but this is particularly useful when developing shared Groovy libraries for Jenkins pipelines
To get started quickly with Pipeline: Copy one of the examples below into your repository and name it Jenkinsfile. Click the New Item menu within Jenkins. Provide a name for your new item (e.g. My-Pipeline) and select Multibranch Pipeline.
To create a simple pipeline from the Jenkins interface, perform the following steps: Click New Item on your Jenkins home page, enter a name for your (pipeline) job, select Pipeline, and click OK. In the Script text area of the configuration screen, enter your pipeline syntax.
You could use the echo
stage:
node {
echo "qwerty"
}
It results in two lines:
[Pipeline] echo
qwerty
Unfortunately it generates two lines, but as far as i know that is the shortest form.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With