Testing DSL scripts using gradle failing

61 views
Skip to first unread message

Nat

unread,
Feb 28, 2024, 5:55:11 AMFeb 28
to job-dsl-plugin
Hi All
Currently I'm testing DSL scripts using gradle with below details:
Gradle Version: 5.3.1
Job DSL Version: 1.70
Jenkins Version: 2.138.2
But having exception for groovy scripts that contains gitTagDiscovery
Please see logs below:

JobScriptsSpec > test script test.groovy FAILED Expected no exception to be thrown, but got 'javaposse.jobdsl.dsl.DslScriptException' at spock.lang.Specification.noExceptionThrown(Specification.java:118) at JobScriptsSpec.test script #file.name(JobScriptsSpec.groovy:25) Caused by: javaposse.jobdsl.dsl.DslScriptException: (script, line 24) No signature of method: javaposse.jobdsl.plugin.structs.DescribableListContext.gitTagDiscovery() is applicable for argument types: () values: [] at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScriptEngine(AbstractDslScriptLoader.groovy:114) at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScripts_closure1(AbstractDslScriptLoader.groovy:61) at groovy.lang.Closure.call(Closure.java:414) at groovy.lang.Closure.call(Closure.java:430) at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScripts(AbstractDslScriptLoader.groovy:46) at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScript(AbstractDslScriptLoader.groovy:87) at JobScriptsSpec.test script #file.name(JobScriptsSpec.groovy:22) Caused by: groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.plugin.structs.DescribableListContext.gitTagDiscovery() is applicable for argument types: () values: [] at javaposse.jobdsl.plugin.structs.DescribableListContext.methodMissing(DescribableListContext.groovy:65) at script$_run_closure1$_closure2$_closure6$_closure7.closure9$_closure10(script:24) at script$_run_closure1$_closure2$_closure6$_closure7.closure9$_closure10(script) at javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:16) at javaposse.jobdsl.plugin.structs.DescribableContext.getValue(DescribableContext.groovy:108) at javaposse.jobdsl.plugin.structs.DescribableContext.methodMissing(DescribableContext.groovy:65) at script$_run_closure1$_closure2$_closure6.closure7$_closure9(script:10) at script$_run_closure1$_closure2$_closure6.closure7$_closure9(script) at javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:16) at javaposse.jobdsl.plugin.structs.DescribableListContext.methodMissing(DescribableListContext.groovy:59) at script$_run_closure1$_closure2.closure6$_closure7(script:6) at script$_run_closure1$_closure2.closure6$_closure7(script) at javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:16) at javaposse.jobdsl.plugin.structs.DescribableContext.getValue(DescribableContext.groovy:122) at javaposse.jobdsl.plugin.structs.DescribableContext.methodMissing(DescribableContext.groovy:65) at script$_run_closure1.closure2$_closure6(script:4) at script$_run_closure1.closure2$_closure6(script) at javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:16) at javaposse.jobdsl.plugin.ExtensionPointHelper$DescribableExtension.call(ExtensionPointHelper.groovy:115) at javaposse.jobdsl.plugin.JenkinsJobManagement.callExtension(JenkinsJobManagement.java:413) at javaposse.jobdsl.dsl.AbstractExtensibleContext.methodMissing(AbstractExtensibleContext.groovy:17) at script.run_closure1$_closure2(script:3) at script.run_closure1$_closure2(script) at javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:16) at javaposse.jobdsl.dsl.jobs.MultibranchWorkflowJob.branchSources(MultibranchWorkflowJob.groovy:22) at script.run_closure1(script:2) at groovy.lang.Closure.call(Closure.java:414) at groovy.lang.Closure.call(Closure.java:430) at javaposse.jobdsl.dsl.JobParent.processItem(JobParent.groovy:238) at javaposse.jobdsl.dsl.JobParent.multibranchPipelineJob(JobParent.groovy:95) at script.run(script:1) at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScript(AbstractDslScriptLoader.groovy:138) at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScriptEngine(AbstractDslScriptLoader.groovy:108) ... 6 more Tried to update the job-dsl version but still error persist. Hopefully someone can help me fix this issue. Thanks

Strahil Nikolov

unread,
Feb 28, 2024, 6:28:00 AMFeb 28
to job-dsl...@googlegroups.com
I recently had such error and in my case it was a missing plugin.
Can you check that all providers are installed correctly?

Best Regards,
Strahil Nikolov

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/81ba06cb-413f-4e04-a03f-81f614bbfab1n%40googlegroups.com.

Nat

unread,
Feb 28, 2024, 7:02:18 AMFeb 28
to job-dsl-plugin
@Strahil

What plugin you added that fix the error?

What do you mean by providers? are you referring to the dependencies?
If yes, looks  like I have installed it correctly.
Thanks

Strahil Nikolov

unread,
Feb 28, 2024, 7:13:54 AMFeb 28
to job-dsl...@googlegroups.com
In my case, the provider (which is actually a dependency) was missing.

Was your code working before ?
Maybe you can share part of it ?

Based on the exception, the method described at line 65 is missing ( DescribableListContext.groovy).

Best Regards,
Strahil Nikolov


Nat

unread,
Feb 29, 2024, 2:36:40 AMFeb 29
to job-dsl-plugin
@Strahil

No, it always fails for groovy scripts that has a trait of gitTagDiscovery()

So I just copied from this example: https://github.com/jenkinsci/job-dsl-plugin/wiki/Testing-DSL-Scripts

And this the groovy script that is failing.

multibranchPipelineJob 'multi-branch', {
    branchSources {
        branchSource {
            source {
                git {
                    id '1232434343234'
                    remote 'https://github.com/test/test2.git'
                    credentialsId 'test-token'

                    traits {
                        gitBranchDiscovery()
                        gitTagDiscovery() // if you need tag discovery
                    }
                }
            }
            strategy {
                defaultBranchPropertyStrategy {
                    props {
                        noTriggerBranchProperty()
                    }
                }
            }
        }
    }
}

Let me know if you need additional information.

Strahil Nikolov

unread,
Feb 29, 2024, 3:24:25 AMFeb 29
to job-dsl...@googlegroups.com
At least in the latest version, I can't find any reference for 'defaultBranchPropertyStrategy' , but I do find gitTagDiscovery().

Maybe you can check if your version has it too: PROTO://JENKINS:PORT/plugin/job-dsl/api-viewer/index.html#method/javaposse.jobdsl.dsl.DslFactory.multibranchPipelineJob

Also, try with 'gitHubTagDiscovery()' method.

Best Regards,
Strahil Nikolov

Nat

unread,
Feb 29, 2024, 4:12:51 AMFeb 29
to job-dsl-plugin
Hi @Strahil

Thanks for the feedback.

I can confirm that gitTagDiscovery() and gitHubTagDiscovery() is available on the version I'm using.

So I tried gitHubTagDiscovery(), but the same error encountered.

Caused by:
            groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.plugin.structs.DescribableListContext.gitHubTagDiscovery() is applicable for argument types: () values: []

Strahil Nikolov

unread,
Feb 29, 2024, 4:57:06 AMFeb 29
to job-dsl...@googlegroups.com
Hi,


Can you update the plugin ?

Best Regards,
Strahil Nikolov

Nat

unread,
Feb 29, 2024, 6:13:42 AMFeb 29
to job-dsl-plugin
Hi @Strahil

Apology for the confusion.
I confirm that below groovy script is working.

multibranchPipelineJob 'multi-branch', {
    branchSources {
        branchSource {
            source {
                git {
                    id '1232434343234'
                    remote 'https://github.com/test/test2.git'
                    credentialsId 'test-token'

                    traits {
                        gitBranchDiscovery()
                        gitTagDiscovery() // if you need tag discovery
                    }
                }
            }
            strategy {
                defaultBranchPropertyStrategy {
                    props {
                        noTriggerBranchProperty()
                    }
                }
            }
        }
    }
}

The issue here is when running "./gradlew build" the test is failing due to the above script which has gitBranchDiscovery()
For other scripts the test are successful, only for this script the test is failing.

Hope this clarify the issue.
Thanks

Reply all
Reply to author
Forward
0 new messages