How to locally run jobs containing DSL from extesions

788 views
Skip to first unread message

Faisal Mansoor

unread,
Oct 14, 2015, 3:40:02 AM10/14/15
to job-dsl-plugin
The following Job DSL works fine when I execute it from within jenkins, but, since the DslScriptLoader does not know about jgivenReports, I get jgivenReports missing error when I run it locally. 

job('jgiven-local-test') {
    publishers {
        jgivenReports {
        }
    }
}

I am running the above job using JobScriptsSpec test script from https://github.com/sheehan/job-dsl-gradle-example

Here is the exception. 

Processing provided DSL script

Expected no exception to be thrown, but got 'javaposse.jobdsl.dsl.DslScriptException'
Expected no exception to be thrown, but got 'javaposse.jobdsl.dsl.DslScriptException'
at spock.lang.Specification.noExceptionThrown(Specification.java:118)
at com.dslexample.JobScriptsSpec.test script #file.name(JobScriptsSpec.groovy:31)
Caused by: javaposse.jobdsl.dsl.DslScriptException: (script, line 4) No signature of method: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.jgivenReports() is applicable for argument types: (script$_run_closure1_closure2_closure3) values: [script$_run_closure1_closure2_closure3@574dcfb4]
at javaposse.jobdsl.dsl.DslScriptLoader.runDslEngineForParent(DslScriptLoader.java:79)
at javaposse.jobdsl.dsl.DslScriptLoader.runDslEngine(DslScriptLoader.java:135)
at javaposse.jobdsl.dsl.DslScriptLoader.runDslEngine(DslScriptLoader.java:131)
at com.dslexample.JobScriptsSpec.test script #file.name(JobScriptsSpec.groovy:24)
Caused by: groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.jgivenReports() is applicable for argument types: (script$_run_closure1_closure2_closure3) values: [script$_run_closure1_closure2_closure3@574dcfb4]
at javaposse.jobdsl.dsl.helpers.AbstractExtensibleContext.methodMissing(AbstractExtensibleContext.groovy:20)
at script.run_closure1_closure2(script:4)
at script.run_closure1_closure2(script)
at javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:14)
at javaposse.jobdsl.dsl.Job.publishers(Job.groovy:627)
at script.run_closure1(script:3)
at groovy.lang.Closure.call(Closure.java:411)
at groovy.lang.Closure.call(Closure.java:427)
at javaposse.jobdsl.dsl.JobParent.processJob(JobParent.groovy:104)
at javaposse.jobdsl.dsl.JobParent.freeStyleJob(JobParent.groovy:44)
at javaposse.jobdsl.dsl.JobParent.job(JobParent.groovy:36)
at script.run(script:2)
at javaposse.jobdsl.dsl.DslScriptLoader.runDslEngineForParent(DslScriptLoader.java:75)
... 3 more

How do I configure DslScriptLoader to process DSLs from external plugins?

Thanks,
Faisal

Mike Volk

unread,
Nov 11, 2015, 4:18:55 PM11/11/15
to job-dsl-plugin
I'm facing the same dilemma with a proprietary plugin that extends the DSL. It works great in the context of a seed job run on a Jenkins instance, but I have not yet sorted out how to execute locally when invoking DslScriptLoader.runDslEngine via a clone of https://github.com/sheehan/job-dsl-gradle-example. And yes, I do have the proprietary plugin on the classpath when executing DslScriptLoader locally.

Reading between the lines, https://groups.google.com/forum/#!topic/job-dsl-plugin/dEoZLcjqA0U seems to suggest that this use case has been forsaken?

Can anybody speak to whether this use case is supported, and if so, how?

Thanks,
Mike

Stephen Murphy

unread,
Dec 30, 2015, 6:12:08 AM12/30/15
to job-dsl-plugin
I've got the same problem, is there really no way of testing third party extension-point plugins? I'm using the same https://github.com/sheehan/job-dsl-gradle-example project, but even in the Jenkins environment I'm unable to unit test proprietary dsl.

Specifically I'm trying to test Promotions, and the https://github.com/codecentric/job-dsl-promotions-plugin dsl plugin. The dsl works fine in the Jenkins environment, but I'm unable to perform any tests using gradle, even as Mike suggests with the job-dsl-promotions-plugin plugin added as a dependency.

Any help or pointers would be gratefully received.

Thanks, Stephen.  

Mike Volk

unread,
Jan 14, 2016, 11:49:35 AM1/14/16
to job-dsl-plugin
Try adding extension discovery (declarative or automated) and depending on your plugin(s) in the job-dsl-gradle-example. You may need to tweak dependencies to ensure you've got everything you need from the Jenkins ecosystem and pull in a bit of processing logic from the jobs-dsl-plugin that isn't visible where you're likely to need it.
Reply all
Reply to author
Forward
0 new messages