Skip to content
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

[JENKINS-37812] No notification re. failed job if agent goes offline during the build #50

Merged
merged 3 commits into from Jan 2, 2019

Conversation

fcojfernandez
Copy link
Contributor

See JENKINS-37812

Class Mailer is implementing the interface SimpleBuildStep. Since the workspace is only used to format the email sent, it's not entirely needed to fail if the workspace is not retrieved. With this PR the email notifying that the build failed will be sent even if the agent goes offline.

Added a test that checks that the email is sent and fails with the precious code.

@reviewbybees @alecharp

Copy link

@jeffret-b jeffret-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me.

Copy link

@varyvol varyvol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to me, but it feels weird that implementing such an important interface is done in a "arbitrary" way. Have you checked the git history to review when this was added and why?

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SimpleBuildStep exists here to provide Pipeline support. This change effectively removes Pipeline Support AFAICT, e.g. AbstractBuild is not Pipeline-compatible. Has it been trsted?

Copy link
Member

@batmat batmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @varyvol.
To make this acceptable IMO, we should double-check we're not breaking compatibility.

I think we should proceed this way:

  • Add a Pipeline test (adding necessary pipeline-plugins in test scope) to check the snippet we find on some places over the web still works:
step([$class: 'Mailer',
     notifyEveryUnstableBuild: true,
     recipients: "some-email@gmail.com",
     sendToIndividuals: true])

E.g.

Ideally: we should probably also have a pipeline test using the more standard new mail step introduced in https://github.com/jenkinsci/workflow-basic-steps-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/steps/MailStep.java and check it still works.

If I'm not clear, please reach out to me, I'm happy to explain this more thoroughly.

@fcojfernandez
Copy link
Contributor Author

@oleg-nenashev @batmat I thought email-ext was the plugin responsible for the Pipeline integration and not this one (I didn't know the correct use of SimpleBuildStep) and according the official documentation of the plugin the way to use it is by adding a Post-build Action. I have to re-write the PR :(

@fcojfernandez
Copy link
Contributor Author

fcojfernandez commented Jan 2, 2019

@oleg-nenashev @batmat @varyvol feedback addressed

  • The jenkins.version property has been updated to be aligned with all the test dependencies
  • I've used the workflow.version 2.6 since it's the version of workflow-plugin which that plugin updated its dependency on mailer-plugin

@alecharp
Copy link
Member

alecharp commented Jan 2, 2019

I do also prefer the current state of the PR. Thank you @fcojfernandez

Copy link
Member

@batmat batmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better to me. 👍 thanks for the test. This is good and critical investment to avoid breaking thing in the future.

Mailbox inbox = getMailbox(RECIPIENT);
inbox.clear();
WorkflowRun b = rule.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0).get());
assertEquals(1, inbox.size());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: given you're already using assertThat below, using hasSize here would yield a clearer message in case of failure.


@Issue("JENKINS-37812")
@Test
public void testPipelineCompatibility() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, and thanks for the tests!

@@ -23,7 +23,8 @@
</licenses>
<properties>
<java.level>7</java.level>
<jenkins.version>1.625.3</jenkins.version>
<jenkins.version>1.642.3</jenkins.version>
<workflow.version>2.6</workflow.version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property does not make much sense, because Pipeline plugin releases are not synchronized starting from 2.0 versions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be change is a following PR, I'll merge in the current state. Thank you for reviewing this @oleg-nenashev.

@alecharp alecharp merged commit 6c8af19 into jenkinsci:master Jan 2, 2019
@fcojfernandez fcojfernandez deleted the JENKINS-37812 branch January 2, 2019 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants