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
Conversation
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.
Makes sense to me.
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.
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?
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.
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?
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.
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.
- https://code.i-harness.com/fr/q/23727cc
- https://baptiste-wicht.com/posts/2017/06/jenkins-tip-send-notifications-fixed-builds-declarative-pipeline.html
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.
@oleg-nenashev @batmat I thought |
@oleg-nenashev @batmat @varyvol feedback addressed
|
I do also prefer the current state of the PR. Thank you @fcojfernandez |
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.
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()); |
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.
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 { |
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.
👍
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.
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> |
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.
This property does not make much sense, because Pipeline plugin releases are not synchronized starting from 2.0 versions
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.
can be change is a following PR, I'll merge in the current state. Thank you for reviewing this @oleg-nenashev.
See JENKINS-37812
Class
Mailer
is implementing the interfaceSimpleBuildStep
. 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