Home > front end >  What library does contain basic jenkins workflow groovy functions?
What library does contain basic jenkins workflow groovy functions?

Time:07-08

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?

CodePudding user response:

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>

CodePudding user response:

Did you try to use

error('Failing build because...')

instead of

error "Foo"

What did you received? It is very strange that groovy find this 'error()' function, but with different argument, may be real problem that other library defined this function and groovy find wrong function instead of jenkins one.

Also strange name of Class due to exception should be something like

No signature of method: static full_package.Class.Funtion()

Could you debug this place in IDEA and check what is a strange class with name 'xxx' and without packages? I tried google strict phrase "No signature of method: static xxx." but it return nothing. May be it is something local in your project?

  • Related