Hi,

Is it possible to run a pipeline model definition job from within a shared 
global library?  I'm trying to take the whole pipeline model and extract it 
into a simple shared lib.  I'm trying to take something like this:

https://github.com/jenkins-infra/pipeline-library/blob/master/vars/buildPlugin.groovy

But use the actual pipeline model definition inside.  The linked example 
above is using base pipeline behavior, not the more idiomatic pipeline 
model version.  I'm trying to do this to produce a common, simple 
Jenkinsfile across many components that all have the exact same build.  I'm 
trying to abstract it into a buildComponent.groovy so that my Jenkinsfile 
for an individual build just has:


buildComponent()

To demonstrate, I've simplified buildComponent.groovy down to barebones.

#!/usr/bin/env groovy


def call(Map params = [:]) {

    def task = {
        pipeline {
            stages {
                stage('do-something') {
                    steps {
                        echo "do something"
                    }
                }
            }
        }
    }

    task()
}

When I try and build a Jenkinsfile using buildComponent(), I get this for 
an error:

[Pipeline] End of Pipeline[Bitbucket] Notifying pull request build result
[Bitbucket] Build result notified
java.lang.NullPointerException: Cannot get property 'stages' on null object
        at 
org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60)
        at 
org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:172)
        at 
org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:47)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
        at 
org.jenkinsci.plugins.pipeline.modeldefinition.Utils.attachDeclarativeActions(Utils.groovy:198)
        at 
org.jenkinsci.plugins.pipeline.modeldefinition.Utils$attachDeclarativeActions$7.call(Unknown
 Source)
        at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
        at 
com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)
        at 
org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.call(jar:file:/var/jenkins_home/plugins/pipeline-model-definition/WEB-INF/lib/pipeline-model-definition.jar!/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy:65)
        at 
buildAngularComponent.call(/var/jenkins_home/jobs/angularui/jobs/van-angularui-affix/branches/PR-7/builds/13/libs/vantage-global-pipeline-libs/vars/buildAngularComponent.groovy:7)
        at 
buildAngularComponent.call(/var/jenkins_home/jobs/angularui/jobs/van-angularui-affix/branches/PR-7/builds/13/libs/vantage-global-pipeline-libs/vars/buildAngularComponent.groovy:18)
        at WorkflowScript.run(WorkflowScript:2)


Am I trying to do something that is not currently possible?  I admit that 
I'm confused by the levels of indirection going on.

Thanks,
Tim

-- 
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/18c8171b-6c13-4fe8-9a5e-2ac330054ac0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to