哪个库包含基本的Jenkins Workflow Groovy功能?

发布于 2025-02-13 16:11:23 字数 863 浏览 0 评论 0 原文

我正在为我的詹金斯(Jenkins)Groovy脚本编写Junit测试。我正在测试的Jenkins脚本包含这样的方法调用:

error "Foo"

当我尝试从IDE(Intellij Idea)运行测试时,我会收到这样的错误:

没有方法的签名:static xxx.error()适用于参数类型:( org.codehaus.groovy.runtime.gstringimpl)value [foo]

所以我想,我需要在我的类中添加一些库来使此<代码错误运行时已知的功能。我尝试了这种Maven依赖性

        <dependency>
            <groupId>org.jenkins-ci.plugins.workflow</groupId>
            <artifactId>workflow-aggregator</artifactId>
            <version>2.5</version>
        </dependency>

,但没有帮助。

因此,我正在努力寻找包含这些基本jenkins的工作流函数: https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps

有什么想法吗?

I am writing a junit test for my Jenkins groovy scripts. My Jenkins script that I am testing contains a method call like this:

error "Foo"

When I try to run the test from my IDE (Intellij IDEA) I get an error like this:

No signature of method: static xxx.error() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values [Foo]

So I suppose, I need to add some library into my classpath to make this error function known to Runtime. I tried this maven dependency

        <dependency>
            <groupId>org.jenkins-ci.plugins.workflow</groupId>
            <artifactId>workflow-aggregator</artifactId>
            <version>2.5</version>
        </dependency>

but it does't help.

So I am struggling to find what library contains these basic Jenkins workflow functions described in here: https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泪是无色的血 2025-02-20 16:11:24

解决方案是使用 jenkins pipeline unit 使所有这些函数/方法都像 echo echo /code>或错误

...
helper.registerAllowedMethod("echo", [String.class], null)
...

在这种情况下,每个测试都应将我们试图测试的代码结合在一起,该代码将通过 jenkinspipelineunit 引擎执行。

The solution is to use Jenkins Pipeline Unit library that makes all those functions/methods like echo or error available and known to the pipeline context:

...
helper.registerAllowedMethod("echo", [String.class], null)
...

In this case every test should wrap-up the piece of code we are trying to test into a small jenkins script that will be executed by the JenkinsPipelineUnit engine.

嘿咻 2025-02-20 16:11:24

源位于在这里。因此,基于

<!-- https://mvnrepository.com/artifact/org.jenkins-ci.plugins.workflow/workflow-basic-steps -->
<dependency>
    <groupId>org.jenkins-ci.plugins.workflow</groupId>
    <artifactId>workflow-basic-steps</artifactId>
    <version>2.24</version>
    <scope>test</scope>
</dependency>

The source is located here. So based on the pom I would say it's in the following dependency.

<!-- https://mvnrepository.com/artifact/org.jenkins-ci.plugins.workflow/workflow-basic-steps -->
<dependency>
    <groupId>org.jenkins-ci.plugins.workflow</groupId>
    <artifactId>workflow-basic-steps</artifactId>
    <version>2.24</version>
    <scope>test</scope>
</dependency>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文