Created
March 10, 2023 18:40
-
-
Save paulogesualdo/6457676ead6676f9637b3793943572b0 to your computer and use it in GitHub Desktop.
To pass a function as a parameter on Jenkins (Groovy)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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