-
Notifications
You must be signed in to change notification settings - Fork 720
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
feat: Use credentials plugin for managing authentication credentials #325
Conversation
This switches the MailAccount class to use credentials instead of directly storing the username/password. There is an upgrade path from the old settings to using credentials.
I'll fix up the tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Looks great overall, and I think users will be delighted to have this functionality. I just see one minor compatibility problem, after which I'm happy to merge and release this.
The changes to src/test/resources/hudson/plugins/emailext/ExtendedEmailPublisherDescriptorTest/persistedConfigurationBeforeDefaultAddress/hudson.plugins.emailext.ExtendedEmailPublisher.xml
and src/test/resources/hudson/plugins/emailext/ExtendedEmailPublisherDescriptorTest/persistedConfigurationBeforeJCasC/hudson.plugins.emailext.ExtendedEmailPublisher.xml
don't seem quite right. These tests are intended to verify that existing serialized state from old versions can still be loaded. Since the plugin should always remain compatible, these files shouldn't ever be changed. So I would suggest reverting the changes to these files.
Speaking of which, since this PR changes the serialization format and adds a new readResolve
method, it would be good to write a similar test. It could be modeled after persistedConfigurationBeforeDefaultAddress
and persistedConfigurationBeforeJCasC
. If you look at those tests, you can see they use @LocalData
with a comment stating "Local data created using Email Extension 2.71 with the following code" and then a bunch of commented out code. The same could be done here using local data from the current released version (with the old username and password). The commented out code isn't strictly necessary, but it is a nice touch. Once you have the hudson.plugins.emailext.ExtendedEmailPublisher.xml
and jenkins.model.JenkinsLocationConfiguration.xml
files from the old version, you can stick them in src/test/resources
like the ones for persistedConfigurationBeforeDefaultAddress
and persistedConfigurationBeforeJCasC
and then write new tests with @LocalData
. Some test cases to consider:
- Loading older state without a corresponding credential should create a new migrated credential
- Loading older state with a corresponding credential should use the existing credential
I will get this done soon, thanks for the review. |
For the two tests you mention, the first case is actually tested via the existing tests (with some updates) since the data is in the older format. I just need to update the test to check for the credential ID (I should check for the text that is used in the update process in readResolve). I will add a test for the second case soon. |
Thanks! |
Released in 2.85. |
This change has introduced strange behavior, it migrated creds to Global Credentials (login is correct for sure), but it fails to use them, and uses root with no password:
After I created new creds entry with correct user, it started to work, but still acting strange:
but few lines later is same log:
|
Can you submit an issue in jira and attach your config.xml for the emailext plugin (make sure to remove any sensitive info). |
Also have same issue after Update plugin. |
Just to clarify, you had existing username/password stored for your connection, you upgraded the plugin and restarted Jenkins and then started a build and the creds were wrong? |
Yes i had valid credentials. After update it was migrated to credentials. After restart the serve and started a build no mail was sent |
Also have the same problem after updating the plugin. I had to create the credentials again to make them work. The automatically converted ones did not work. |
Is there any solution or workaround available? Using 2.85. Rollback to 2.84 results in other errors when sending email. I'm reading "had to create the credentials again to make them work", but: In the Jenkins System Configuration ("E-mail Notification") I can enter username/password only, a cannot assign any saved credential. Re-entering username/password does not change anything. The log of a simple freestyle test job sending an email shows: 10:53:26 DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle] Sending the test email from System Configuration succeeds. Any help is greatly appreciated. |
@cfischer-oo-software did you resolve this issue? Now I am upgrading to 2.89 to see if it helps. |
This switches the MailAccount class to use credentials instead of directly storing the username/password. There is an upgrade path from the old settings to using credentials.
https://issues.jenkins.io/browse/JENKINS-66849
Hacktoberfest submission