3

I'm working with jenkins pipeline and have a shared global library. I created several functions that users can use, however the main problem I'm facing is having better output in the Console Output and Blue Ocean: Is there a way to create in groovy a named block (such as when calling the sh function all the output is contained inside)? I tried playing around with stages like so:

stage('Checkout') {
    checkout scm
    stage('Some Custom Step') {
        // Some custom step logic
    }
}

However this approach didn't work. I know you can create custom steps by writing plugins for Jenkins and then calling the function in your groovy script, I was just wandering if there is a way to write such a thing directly in groovy, say, in my library.

Also is there a way to silence output?

sh '<some command with meaningful output>'
sh '<some random output not relevant to the user>' // 
Silence somehow
echo 'step finished successfuly!'

Thanks for everyone in advance

user9836191
  • 53
  • 1
  • 5
  • For that you presumably would need to write your own plugin to provide that step. After writing one myself I found it pretty easy to do - if you got some java background.. – Joerg S Jul 22 '18 at 11:22

1 Answers1

1

I don't really know if you can write a step inside pipeline and would like to know that too, but as for silencing the output you can do as mentioned on this question: redirect output to '/dev/null'.

It should be something like

sh '<some command with meaningful output>'
sh '<some random output not relevant to the user> > dev/null'