Skip to content

Instantly share code, notes, and snippets.

@paulogesualdo
Created March 10, 2023 18:40
Show Gist options
  • Save paulogesualdo/6457676ead6676f9637b3793943572b0 to your computer and use it in GitHub Desktop.
Save paulogesualdo/6457676ead6676f9637b3793943572b0 to your computer and use it in GitHub Desktop.
To pass a function as a parameter on Jenkins (Groovy)
def commonFunction () {
echo "Hello inception"
}
def commonFunctionAsVariable = this.&commonFunction
def callFunction(functionAsVariable) {
functionAsVariable()
}
pipeline {
agent any
stages {
stage('Inception') {
steps {
script {
callFunction(commonFunctionAsVariable)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment