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

Adding support for configuring when matrix projects notify. #547

Merged
merged 7 commits into from
Apr 9, 2019

Conversation

kcboschert
Copy link
Contributor

@kcboschert kcboschert commented Apr 2, 2019

This adds support for users to configure whether a matrix project notifies:

  1. Upon the completion of the parent job.
  2. Upon the completion of each child job.
  3. Both of the above.

This implementation solves #198 by pulling in similar logic from the hipchat and email-ext plugin.

While this does add the matrix-project as a dependency, this seems to be the pattern for how other publishers handle this, as seen by the plugins mentioned above. If this is acceptable, I'll add tests and request final review for merging.

Screen Shot 2019-04-02 at 2 17 07 PM

Fixes #198

@timja
Copy link
Member

timja commented Apr 2, 2019

Hey, I'll take a look at this soon, could you add the needed tests please?

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

looking good

@@ -168,6 +176,14 @@ public CommitInfoChoice getCommitInfoChoice() {
return commitInfoChoice;
}

public MatrixTriggerMode getMatrixTriggerMode() {
if (matrixTriggerMode == null) {
return MatrixTriggerMode.ONLY_CONFIGURATIONS;
Copy link
Member

Choose a reason for hiding this comment

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

can you initialise it to this and have the getter just be dumb?

@@ -341,20 +362,20 @@ public SlackNotifier(CommitInfoChoice commitInfoChoice) {
public SlackNotifier(final String baseUrl, final String teamDomain, final String authToken, final boolean botUser, final String room, final String tokenCredentialId,
final String sendAs, final boolean startNotification, final boolean notifyAborted, final boolean notifyFailure,
final boolean notifyNotBuilt, final boolean notifySuccess, final boolean notifyUnstable, final boolean notifyRegression, final boolean notifyBackToNormal,
final boolean notifyRepeatedFailure, final boolean includeTestSummary, final boolean includeFailedTests,
final boolean notifyRepeatedFailure, final boolean includeTestSummary, final boolean includeFailedTests, MatrixTriggerMode matrixTriggerMode,
Copy link
Member

Choose a reason for hiding this comment

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

need to deprecate the old constructor and add a new one, modifying the constructor breaks compatibility

@timja timja added the fix label Apr 2, 2019
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

I noticed an unused import when I was reviewing this so I've added a checkstyle rule for it,

Resolved conflicts for you but can you take a look please

public MatrixAggregator createAggregator(MatrixBuild matrixBuild, Launcher launcher, BuildListener buildListener) {
return new MatrixAggregator(matrixBuild, launcher, buildListener) {
@Override
public boolean startBuild() throws InterruptedException, IOException {
Copy link
Member

Choose a reason for hiding this comment

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

IntelliJ says these exception declarations are unneeded?

Suggested change
public boolean startBuild() throws InterruptedException, IOException {
public boolean startBuild() {

}

@Override
public boolean endBuild() throws InterruptedException, IOException {
Copy link
Member

Choose a reason for hiding this comment

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

IntelliJ says these exception declarations are unneeded?

Suggested change
public boolean endBuild() throws InterruptedException, IOException {
public boolean startBuild() {

…ing compatibility and removing unnecessary invocations/exceptions.
@timja
Copy link
Member

timja commented Apr 4, 2019

The build is currently failing for findbug violations:


[2019-04-04T01:49:59.720Z] [INFO] The method name jenkins.plugins.slack.Messages.FailedToParseSlackResponse(Object) doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 40] NM_METHOD_NAMING_CONVENTION

[2019-04-04T01:49:59.720Z] [INFO] The method name jenkins.plugins.slack.Messages.MigratedCredentialDescription() doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 108] NM_METHOD_NAMING_CONVENTION

[2019-04-04T01:49:59.720Z] [INFO] The method name jenkins.plugins.slack.Messages.NotificationFailed() doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 220] NM_METHOD_NAMING_CONVENTION

[2019-04-04T01:49:59.720Z] [INFO] The method name jenkins.plugins.slack.Messages.NotificationFailedWithException(Object) doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 176] NM_METHOD_NAMING_CONVENTION

[2019-04-04T01:49:59.720Z] [INFO] The method name jenkins.plugins.slack.Messages.SlackSendStepDisplayName() doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 87] NM_METHOD_NAMING_CONVENTION

[2019-04-04T01:49:59.720Z] [INFO] The method name jenkins.plugins.slack.Messages.SlackSendStepValues(Object, Object, Object, Object, Object, Object) doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 257] NM_METHOD_NAMING_CONVENTION

[2019-04-04T01:49:59.720Z] [INFO] The method name jenkins.plugins.slack.Messages.SlackSendStepValuesEmptyMessage() doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 199] NM_METHOD_NAMING_CONVENTION

[2019-04-04T01:49:59.721Z] [INFO] 

[2019-04-04T01:49:59.721Z] 

[2019-04-04T01:49:59.721Z] 

[2019-04-04T01:49:59.721Z] To see bug detail using the Findbugs GUI, use the following command "mvn findbugs:gui"

[2019-04-04T01:49:59.721Z] 

[2019-04-04T01:49:59.721Z] 

[2019-04-04T01:49:59.721Z] 

[2019-04-04T01:49:59.721Z] [INFO] ------------------------------------------------------------------------

[2019-04-04T01:49:59.721Z] [INFO] BUILD FAILURE

[2019-04-04T01:49:59.721Z] [INFO] ------------------------------------------------------------------------

[2019-04-04T01:49:59.721Z] [INFO] Total time: 03:21 min

[2019-04-04T01:49:59.721Z] [INFO] Finished at: 2019-04-04T01:49:59Z

[2019-04-04T01:49:59.721Z] [INFO] ------------------------------------------------------------------------

[2019-04-04T01:49:59.721Z] [ERROR] Failed to execute goal org.codehaus.mojo:findbugs-maven-plugin:3.0.5:check (findbugs) on project slack: failed with 7 bugs and 0 errors -> [Help 1]

[2019-04-04T01:49:59.721Z] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:findbugs-maven-plugin:3.0.5:check (findbugs) on project slack: failed with 7 bugs and 0 errors 

Honestly not sure why it's picking those up, all the other methods in there seem to start with a capital.

Any idea @Casz?

@jetersen
Copy link
Member

jetersen commented Apr 4, 2019

no idea why findbugs is looking at messages 😆 I'd suggest updating parent pom and getting spotbugs instead.

Should be setup to ignore them.

<FindBugsFilter>
<Match>
<Class name="~.*\.Messages" />
<Bug pattern="NM_METHOD_NAMING_CONVENTION" />
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be needed...

@jetersen
Copy link
Member

jetersen commented Apr 8, 2019

Please update parent POM to the least instead, should solve your issue
https://github.com/jenkinsci/slack-plugin/blob/master/pom.xml#L9

@kcboschert
Copy link
Contributor Author

@Casz Forgive my ignorance, but I'm not a Java developer. Can you give me more detail on what you're asking?

@jetersen
Copy link
Member

jetersen commented Apr 8, 2019

Revert last addition and change the parent pom to the latest version: https://github.com/jenkinsci/plugin-pom/blob/master/CHANGELOG.md

slack-plugin/pom.xml

Lines 6 to 10 in a68a8b0

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.33</version>
</parent>

3.33 is already quite old please bump to latest, which is 3.42

@kcboschert
Copy link
Contributor Author

Updating to 3.42 gives the same errors with spotbugs:

[INFO] --- spotbugs-maven-plugin:3.1.11:check (default-cli) @ slack ---
[INFO] BugInstance size is 7
[INFO] Error size is 0
[INFO] Total bugs: 7
[ERROR] The method name jenkins.plugins.slack.Messages.FailedToParseSlackResponse(Object) doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 40] NM_METHOD_NAMING_CONVENTION
[ERROR] The method name jenkins.plugins.slack.Messages.MigratedCredentialDescription() doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 108] NM_METHOD_NAMING_CONVENTION
[ERROR] The method name jenkins.plugins.slack.Messages.NotificationFailed() doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 220] NM_METHOD_NAMING_CONVENTION
[ERROR] The method name jenkins.plugins.slack.Messages.NotificationFailedWithException(Object) doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 176] NM_METHOD_NAMING_CONVENTION
[ERROR] The method name jenkins.plugins.slack.Messages.SlackSendStepDisplayName() doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 87] NM_METHOD_NAMING_CONVENTION
[ERROR] The method name jenkins.plugins.slack.Messages.SlackSendStepValues(Object, Object, Object, Object, Object, Object) doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 257] NM_METHOD_NAMING_CONVENTION
[ERROR] The method name jenkins.plugins.slack.Messages.SlackSendStepValuesEmptyMessage() doesn't start with a lower case letter [jenkins.plugins.slack.Messages] At Messages.java:[line 199] NM_METHOD_NAMING_CONVENTION
[INFO]

@jetersen
Copy link
Member

jetersen commented Apr 8, 2019

I think it is mocking that is pulling them into view

Could you try fixing them to lower case?

@jetersen
Copy link
Member

jetersen commented Apr 8, 2019

@timja I think you would benefit from adding Travis. Jenkins CI is on the slow side...

Build #8 (Apr 8, 2019 9:20:05 PM) unacceptable waiting time.

@timja
Copy link
Member

timja commented Apr 9, 2019

Tested regression, and light touch on the new feature (I don't know anything about matrix, but clicking through and running a build worked)

image

@timja timja merged commit 12bfda1 into jenkinsci:master Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants