Search code examples
jenkinsgroovypluginsconfiguremailer

Programmatically Configuring Jenkins Mailer Plugin in Groovy Script


As the title suggests, I am trying to configure the Mailer plugin in a Groovy script to set fields such as the username and password. Is there a way to do that?

I have tried referencing the Jenkins API documentation and managed to get the plugin as such:

Jenkins.instance.pluginManager.getPlugin('mailer').getPlugin().configure(...)

However, I'm not sure if that "configure" method does what I need.


Solution

  • This perhaps ... ?

    from: https://github.com/Praqma/JenkinsAsCodeReference/blob/master/dockerizeit/master/globalconfig.groovy

      def jlc = JenkinsLocationConfiguration.get()
      jlc.setAdminAddress(config.global.jenkinsAdminEmail)
      jlc.save()