Jenkins WorkflowScript:加载库失败

问题描述

我使用 jenkins 作为我的 CI/CD,这突然开始发生。 Jenkins 文件从不同的存储库加载库,但位于同一个 git 帐户,并且工作正常。现在所有声明性管道都不起作用并抛出这个奇怪的错误
詹金斯版本:2.263.3
Java 11
詹金斯档案:
#!/usr/bin/env groovy

@Library('jenkins-shared-library') _

MyPipeline()

java.lang.NullPointerException
    at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.lambda$retrieve$0(SCMSourceRetriever.java:83)
    at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrySCMOperation(SCMSourceRetriever.java:98)
    at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrieve(SCMSourceRetriever.java:83)
    at org.jenkinsci.plugins.workflow.libs.LibraryAdder.retrieve(LibraryAdder.java:157)
    at org.jenkinsci.plugins.workflow.libs.LibraryAdder.add(LibraryAdder.java:138)
    at org.jenkinsci.plugins.workflow.libs.LibraryDecorator$1.call(LibraryDecorator.java:125)
    at org.codehaus.groovy.control.compilationunit.applyToPrimaryClassNodes(compilationunit.java:1065)
    at org.codehaus.groovy.control.compilationunit.doPhaSEOperation(compilationunit.java:603)
    at org.codehaus.groovy.control.compilationunit.processphaSEOperations(compilationunit.java:581)
    at org.codehaus.groovy.control.compilationunit.compile(compilationunit.java:558)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
    at groovy.lang.groovyshell.parseClass(groovyshell.java:688)
    at groovy.lang.groovyshell.parse(groovyshell.java:700)
    at org.jenkinsci.plugins.workflow.cps.cpsgroovyshell.doParse(cpsgroovyshell.java:133)
    at org.jenkinsci.plugins.workflow.cps.cpsgroovyshell.reparse(cpsgroovyshell.java:126)
    at org.jenkinsci.plugins.workflow.cps.cpsFlowExecution.parseScript(cpsFlowExecution.java:561)
    at org.jenkinsci.plugins.workflow.cps.cpsFlowExecution.start(cpsFlowExecution.java:522)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup Failed:
WorkflowScript: Loading libraries Failed

1 error

    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
    at org.codehaus.groovy.control.compilationunit.applyToPrimaryClassNodes(compilationunit.java:1085)
    at org.codehaus.groovy.control.compilationunit.doPhaSEOperation(compilationunit.java:603)
    at org.codehaus.groovy.control.compilationunit.processphaSEOperations(compilationunit.java:581)
    at org.codehaus.groovy.control.compilationunit.compile(compilationunit.java:558)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
    at groovy.lang.groovyshell.parseClass(groovyshell.java:688)
    at groovy.lang.groovyshell.parse(groovyshell.java:700)
    at org.jenkinsci.plugins.workflow.cps.cpsgroovyshell.doParse(cpsgroovyshell.java:133)
    at org.jenkinsci.plugins.workflow.cps.cpsgroovyshell.reparse(cpsgroovyshell.java:126)
    at org.jenkinsci.plugins.workflow.cps.cpsFlowExecution.parseScript(cpsFlowExecution.java:561)
    at org.jenkinsci.plugins.workflow.cps.cpsFlowExecution.start(cpsFlowExecution.java:522)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE ```

解决方法

您能否签入:管理 jenkins > 配置系统 > 全局管道库? 你应该有这样的事情: enter image description here

,

我想在这里添加的一件事是,您需要在根级别或文件夹级别添加共享库。你真的不能在Job级别添加