I want to add timestamps()
and colorizeOutput()
features to our pipeline libraries. I find the wrappers {}
in Jenkins documentation:
job('example') {
wrappers {
colorizeOutput()
timestamps()
}
}
I don`t get how to add wrappers to out library which looks like that:
// file ..src/helpers/Builder.groovy
package helpers.sw_main
def doSomething() {
// some Groovy stuff here
}
def doSomethingElse() {
// do something else
}
Our job pipeline looks like that:
#!/usr/bin/env groovy
// this is our library with custom methods
@Library('ext-lib')
def builder = new helpers.Builder()
node {
try {
stage('Some Stage') {
builder.doSomething()
}
}
catch (err) {
throw err
}
}
So, I want to add timestamps and ansi-colors to every function from library. Of course, I can do it with wrapping every function with
timestamps() {
colorizeOutput() {
// function body
}
}
But its a little stupid.
So can I easily wrap pipeline or library?