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-dsl

thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/4b3d1871-e35b-48f0-b0b6-82c2ffb46ec7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to