Configuration-as-code-plugin: SMTP server config in Email-Ext seems to be loaded, but disappears

Created on 6 Mar 2019  路  4Comments  路  Source: jenkinsci/configuration-as-code-plugin

  • [2.150.2 ] Jenkins version
  • [1.7 ] Plugin version
  • [Debian GNU/Linux 9 (stretch) ] OS

Steps to reproduce:

  • Use the following config file:
    plugins.yaml:
unclassified:
  extendedEmailPublisher:
    smtpServer: "smtp.something.something.net"
  • And the following Dockerfile:
FROM jenkins/jenkins:lts

USER jenkins

COPY plugins.yaml /usr/share/jenkins/ref/casc_configs/

ENV CASC_JENKINS_CONFIG /usr/share/jenkins/ref/casc_configs
# Install plugins

RUN /usr/local/bin/install-plugins.sh  configuration-as-code configuration-as-code-support email-ext

ENV JAVA_OPTS="-Djenkins.install.runSetupWizard=false"
  • Build the image and run with default entrypoint and -p 8080:8080
  • Wait for Jenkins is fully up and running...
  • Open
  • smtp.something.something.net is visible in Extended E-mail Notification/SMTP server
  • click "Save"
  • open http://localhost:8080/configure again
  • value in Extended E-mail Notification/SMTP server disappeared!

But it seems to be something with this value even before you open _/configure_ for the first time and click "Save", because sending email after failed job fails at the connection.

plugin-compatibility stale

Most helpful comment

Ok, I investigated it further. It seems issue disappears when smtp settings are duplicated in mailer:
plugins.yaml:

unclassified:
  mailer:
    smtpHost: "smtp.something.something.net"
  extendedEmailPublisher:
    smtpServer: "smtp.something.something.net"

Now in configuration page, smtp.something.something.net is visible both in Extended E-mail Notification/SMTP server and E-mail Notification/SMTP server. And both persist after pressing "Save". And email notifications work as expected.

Interestingly, notifications seem to work even when smtp server name and port is provided only in mailer. So all that you need is:

unclassified:
  mailer:
    smtpHost: "smtp.something.something.net"
    smtpPort: "25"
  extendedEmailPublisher:
     smtpUsername: "blahblah"
     smtpPassword: "${SMTP_PASSWORD}"

But that's more of an issue of the plugin itself, not JCasC.

Anyway, although it can be worked around, the issue on JCasC side remains: setting value of extendedEmailPublisher/smtpHost in .yaml doesn't have the same effect as setting it in UI.

All 4 comments

Ok, I investigated it further. It seems issue disappears when smtp settings are duplicated in mailer:
plugins.yaml:

unclassified:
  mailer:
    smtpHost: "smtp.something.something.net"
  extendedEmailPublisher:
    smtpServer: "smtp.something.something.net"

Now in configuration page, smtp.something.something.net is visible both in Extended E-mail Notification/SMTP server and E-mail Notification/SMTP server. And both persist after pressing "Save". And email notifications work as expected.

Interestingly, notifications seem to work even when smtp server name and port is provided only in mailer. So all that you need is:

unclassified:
  mailer:
    smtpHost: "smtp.something.something.net"
    smtpPort: "25"
  extendedEmailPublisher:
     smtpUsername: "blahblah"
     smtpPassword: "${SMTP_PASSWORD}"

But that's more of an issue of the plugin itself, not JCasC.

Anyway, although it can be worked around, the issue on JCasC side remains: setting value of extendedEmailPublisher/smtpHost in .yaml doesn't have the same effect as setting it in UI.

This isn't a JCasc bug, it's an issue with one of the mailer plugins

@przecze Is there a Jenkins JIRA issue for it? The most of plugins are maintained there, and its maintainers won;t see this issue

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings