Search code examples
jenkinsjenkins-job-dsl

Jenkins job dsl configure block with "plugin="


I am trying to add new plugin via configure block to my jenkins jobs.

What I neeed is:

<jenkins.plugins.mattermost.MattermostNotifier plugin="[email protected]">

What I get is:

 <jenkins.plugins.mattermost.MattermostNotifier>

My groovy script:

 job('newjob') {
        publishers {        
            if (!name.startsWith('_review')) {
                configure { project -> 
                    project / publishers / 'jenkins.plugins.mattermost.MattermostNotifier' << 'mattermost' {

                    } 
                }
            }
        }
    }

How can I add this

[email protected]

to the XML block?


Solution

  • You don't explicitly add the version number to the plugin declaration. Instead, add it to the project's configuration.

    Jenkins is moving in the direction of Configuration as Code with plugins such as the JCasC plugin making it's way into the Jenkins core platform.

    As seen from the documentation, you can configure other plugins through this plugin which was accepted as native Jenkins feature.