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

查看:20
本文介绍了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")

我安装了所有管道插件,尤其是 workflow-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

推荐答案

Pipeline Global Library 需要一个 Git 推送事件来更新 Jenkins 嵌入式工作流库 git repo.

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

推送触发 UserDefinedGlobalVariableList.rebuild() 方法参见:https://github.com/jenkinsci/workflow-cps-global-lib-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/cps/global/UserDefinedGlobalVariableList.java

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:

//获取在Git Push上重建全局库的Pipeline Global Library Jenkins Extension列表扩展 = ExtensionList.lookup(UserDefinedGlobalVariableList.class);extensions.get(0).rebuild()//可能想在此处添加检查以确保扩展不为空

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

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