Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RestApiScriptRunner with auto generated DSL? #62

Open
denisrosca opened this issue Nov 17, 2016 · 1 comment
Open

Use RestApiScriptRunner with auto generated DSL? #62

denisrosca opened this issue Nov 17, 2016 · 1 comment

Comments

@denisrosca
Copy link

This is more of a question than an issue, but I was wondering if it is possible to use the RestApiScriptRunner to execute a dsl configuration containing calls to a "auto generated" dsl?
I have a use case where a seed job tries to create a jenkins job containing a slack notifier:

job {
	publishers {
		slackNotifier {
			room('my-slack-room')
			notifyAborted(true)
			notifyFailure(true)
			notifyNotBuilt(true)
			notifyUnstable(true)
			notifyBackToNormal(true)
			notifySuccess(false)
			notifyRepeatedFailure(true)
		}
	}
}

I get the following exception:

Caused by: javaposse.jobdsl.dsl.DslScriptException: (script, line 45) No signature of method: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.slackNotifier() is applicable for argument types: (script$_run_closure1_closure4_closure10_closure11_closure12) values: [script$_run_closure1_closure4_closure10_closure11_closure12@76884e4b]
Possible solutions: stashNotifier(), stashNotifier(groovy.lang.Closure)
	at javaposse.jobdsl.dsl.DslScriptLoader.runScriptEngine(DslScriptLoader.groovy:135)
	at javaposse.jobdsl.dsl.DslScriptLoader.runScriptsWithClassLoader_closure1(DslScriptLoader.groovy:78)
	at groovy.lang.Closure.call(Closure.java:423)
	at groovy.lang.Closure.call(Closure.java:439)
	at javaposse.jobdsl.dsl.DslScriptLoader.runScriptsWithClassLoader(DslScriptLoader.groovy:68)
	at javaposse.jobdsl.dsl.DslScriptLoader.runScripts(DslScriptLoader.groovy:44)
	at javaposse.jobdsl.dsl.DslScriptLoader.runScript(DslScriptLoader.groovy:58)
	at javaposse.jobdsl.dsl.DslScriptLoader.runDslEngine(DslScriptLoader.groovy:182)
	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.slackNotifier() is applicable for argument types: (script$_run_closure1_closure4_closure10_closure11_closure12) values: [script$_run_closure1_closure4_closure10_closure11_closure12@76884e4b]
Possible solutions: stashNotifier(), stashNotifier(groovy.lang.Closure)
	at javaposse.jobdsl.dsl.AbstractExtensibleContext.methodMissing(AbstractExtensibleContext.groovy:19)
	at script.run_closure1_closure4_closure10_closure11(script:45)
	at script.run_closure1_closure4_closure10_closure11(script)
	at javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:16)
	at javaposse.jobdsl.dsl.Job.publishers(Job.groovy:640)
	at script.run_closure1_closure4_closure10(script:42)
	at script.run_closure1_closure4_closure10(script)

The root cause seems to be that the slack plugin uses the automatically generated dsl feature, thus the 'slackNotifier' method is not present when executing the script using the rest runner.

@ssbarnea
Copy link

I think I encountered something very similar, I have code that works well under Jenkins but it fails with a similar groovy.lang.MissingMethodException: No signature of method.

This should be able to reproduce it:

def xxx() {
}

xxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants