0
votes

How I can create Jenkins job via Jenkins DSL using the custom plugin? I have tried to implement WebHook Plugin: https://github.com/jenkinsci/generic-webhook-trigger-plugin But via DSL I receiving an error that genericTrigger class does not exist.

Caused by: groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.GenericTrigger() is applicable for argument types: (script$_run_closure2$_closure5$_closure11) values: [script$_run_closure2$_closure5$_closure11@7f132176]

I have tried to add this plugin to gradlew dependencies :

dependencies {
    compile 'org.jenkins-ci.plugins:generic-webhook-trigger:1.4'
}

But still the same error. How I correct import them? I have tried to clone from github these classes, but dependencies required other ones, external. How to correct do this?

P.S. Plugin has been installed on Jenkins

1

1 Answers

0
votes

The built-in DSL from the JobDSL plugin does not offer a support for all possible plugins available on Jenkins.

However, they do provide 2 additional ways to configure "non-supported" plugins:

  1. Dynamic DSL
  2. The Configure Block

The first one, the Dynamic DSL, looks very much on the built-in DSL. To understand if the plugin supports it, the easiest way is to checkout the API viewer on your jenkins instance (https://[your_jenkins_domain]/plugin/job-dsl/api-viewer/index.html)

Search for your plugin and if it supports it, you'll see something like the following which shows a dynamic dsl for the slack notification plugin:

dynamic-dsl-example

Find more information on the Dynamic DSL here.

If it's not supported by the Dynamic DSL, then you can still configure it through the "The Configure Block". This part is a bit harder as it requires to parse XML with Groovy. But everything is nicely explained in their documentation too.

Finally, there are slides about Automating Jenkins. You'll find an example for both cases. And a blog post about the Configure Block which should still be applicable.