Jenkins Pipelines:为什么不加载CPS Global Lib? [英] Jenkins Pipelines: Why is CPS Global Lib not loading?

查看:331
本文介绍了Jenkins Pipelines:为什么不加载CPS Global Lib?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在管道库插件.我制作了一个包含以下文件的存储库:

I'm following the tutorial on the pipeline library plugin. I made a repository containing the following files:

D:.
│   Test.groovy
│   
├───src
└───vars
        helloWorld.groovy

helloWorld.groovy包含:

helloWorld.groovy contains:

def call(name){
    echo "Hello world, ${name}"
}

Test.groovy包含:

Test.groovy contains:

helloWorld("Joe")

我安装了所有管道插件,尤其是工作流-cps-global-lib-plugin.然后,我创建了一个新的管道作业,在其中加载了此存储库并将脚本路径设置为Test.groovy.当我运行此作业时,出现以下错误:

I installed all the pipeline plugins, in particular workflow-cps-global-lib-plugin. Then I created a new pipeline job in which I load this repository and set the Script Path to Test.groovy. When I run this job I get the following error:

java.lang.NoSuchMethodError: No such DSL method 'helloWorld' found among [archive, bat, build, catchError, checkout, deleteDir, dir, echo, emailext, error, fileExists, git, input, isUnix, jiraComment, jiraIssueSelector, jiraSearch, load, mail, node, parallel, properties, pwd, readFile, readTrusted, retry, sh, sleep, stage, stash, step, svn, timeout, tool, unarchive, unstash, waitUntil, withEnv, wrap, writeFile, ws]

为什么helloWorld步骤未定义?这是我已安装的插件列表: http://pastebin.com/xiMMub8J

Why is the helloWorld step not defined? Here is my list of installed plugins: http://pastebin.com/xiMMub8J

推荐答案

管道全局库希望通过Git推送事件来更新Jenkins嵌入式工作流库git repo.

The Pipeline Global Library expects a Git push event to update the Jenkins embedded workflow-libs git repo.

推送会触发UserDefinedGlobalVariableList.rebuild()方法,请参见:

A push triggers the UserDefinedGlobalVariableList.rebuild() method see: https://github.com/jenkinsci/workflow-cps-global-lib-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/cps/global/UserDefinedGlobalVariableList.java

这是一个 groovy脚本将GitHub存储库拉入Jenkins workflow-libs存储库,然后通过以下方式重新加载它而无需重新启动:

Here is a groovy script that pulls a GitHub repo into the Jenkins workflow-libs repos and then reloads it without a restart via:

//Get Pipeline Global Library Jenkins Extension that rebuilds global library on Git Push List extensions = ExtensionList.lookup(UserDefinedGlobalVariableList.class); extensions.get(0).rebuild() //may want to add a check here to make sure extensions isn't null

//Get Pipeline Global Library Jenkins Extension that rebuilds global library on Git Push List extensions = ExtensionList.lookup(UserDefinedGlobalVariableList.class); extensions.get(0).rebuild() //may want to add a check here to make sure extensions isn't null

这篇关于Jenkins Pipelines:为什么不加载CPS Global Lib?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆