Hi,
I want to provide a global var on my brand new jenkins2
here is my function
// workflowLibs/vars/mavenBuild
def call(def url=null, def branch=null, def mvnArgs=["-U", "clean", "deploy"]) {
boolean defaultScm = ( url == null || branch == null )
node {
stage "Checkout"
if (defaultScm) {
checkout scm
} else {
git url: "${url}", branch: "${branch}"
}
stage "Build"
def mvnHome = tool 'MVN33'
def mvnCommamd = ["${mvnHome}/bin/mvn"] + mvnArgs
sh "${mvnCommamd.join(" ")}"
}
}The goal of this function is to be called in a Jenkinsfile like this
mavenBuild
mavenBuild mvnArgs: ["-X", "clean", "test"]
....
first syntax works as expected, but if I call my var with a parameter, it doesn't take account and always use default params.
Is it possible to create global var with default values and named parameter ?
I know I can use this syntax :
https://github.com/jenkinsci/workflow-cps-global-lib-plugin/blob/master/README.md#define-more-structured-dslthanks.