Jenkins groovy全局库声明性管道错误

Jenkins groovy全局库声明性管道错误,jenkins,jenkins-pipeline,jenkins-groovy,jenkins-declarative-pipeline,Jenkins,Jenkins Pipeline,Jenkins Groovy,Jenkins Declarative Pipeline,我的詹金斯档案有以下两行 @Library(['global-jenkins-lib@master']) _ driBuildPipeline {} 它在全局jenkins库的VAR dir下调用“driBuildPipeline.groovy” 我的脚本如下所示: def call(body) { def pipelineParams = [:] body.resolveStrategy = Closure.DELEGATE_FIRST body.delegate =

我的詹金斯档案有以下两行

@Library(['global-jenkins-lib@master']) _
driBuildPipeline {}
它在全局jenkins库的VAR dir下调用“driBuildPipeline.groovy”

我的脚本如下所示:

def call(body) {
    def pipelineParams = [:]
    body.resolveStrategy = Closure.DELEGATE_FIRST
    body.delegate = pipelineParams
    body()
    println("Starting Pipeline....")
pipeline {
    agent {
        kubernetes {
            label 'DRIOrchestrationBuild'
            yamlFile 'build-pod.yaml'
        }
    }
    options {
        buildDiscarder(logRotator(numToKeepStr: '5', daysToKeepStr: '10'))
        timestamps()
    }
    environment {
        gsm = 'Name'
    }
    stages {
        stage('DRI Orchestration Build Preparation') {
            steps {
                sh """
                    echo 'Prepering.........' /
                    ls -l
                    """
            }
        }
        stage('DRI Orchestration Build Start') {
            steps {
                sh "echo DRI Orchestration Build Started...."
            }
        }
    }
}

}
但是,当我运行我的构建时,我得到了下面的错误日志

refs/heads/master:refs/remotes/origin/master # timeout=10
Checking out Revision 3e8279cf8426831010fc5a0b0394201fde4b1790 (master)
git config core.sparsecheckout # timeout=10
git checkout -f 3e8279cf8426831010fc5a0b0394201fde4b1790 # timeout=10
Commit message: "Update driBuildPipeline.groovy"
git rev-list --no-walk 8d87b4f16d320639cc27fcbe6221fa5b6cbe065a # timeout=10
[Pipeline] Start of Pipeline
[Pipeline] End of Pipeline
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s

GitHub has been notified of this commit’s build result

java.lang.NullPointerException: Cannot invoke method call() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:35)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:163)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
at driBuildPipeline.call(driBuildPipeline.groovy:5)
at WorkflowScript.run(WorkflowScript:2)
at cps.transform (Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixName(FunctionCallBlock.java:78)
at sun.reflect.GeneratedMethodAccessor326.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
完成:失败


这是一种bug还是我做错了。

我不确定
java.lang.NullPointerException:无法调用方法调用()在null对象上
但我知道您需要在
Manage jenkins
-
Configure system
-
全局管道库中添加共享库

您的全局var方法需要类型为
Closure
的参数,并且您没有将任何内容作为参数传递给该方法;因此
无法对空对象调用方法调用()。如果不需要参数,则应将其从方法定义中删除。