Skip to content

Added feature to allow user to have a wildcard for selecting "Any Pipeli...#466

Merged
arvindsv merged 4 commits intogocd:masterfrom
lcs777:master
Sep 8, 2014
Merged

Added feature to allow user to have a wildcard for selecting "Any Pipeli...#466
arvindsv merged 4 commits intogocd:masterfrom
lcs777:master

Conversation

@lcs777
Copy link
Contributor

@lcs777 lcs777 commented Sep 1, 2014

...ne" or "Any Stage" within a pipeline when subscribing to email notifications.

This pull request is to let a user select to get notifications for any event on all pipelines or all stages on a particular pipeline.

This is useful because it allows users to be able to be notified on events for a pipeline when it changes without having to update their notifications everytime a pipeline changes.

…eline" or "Any Stage" within a pipeline when subscribing to email notifications.
@lcs777
Copy link
Contributor Author

lcs777 commented Sep 4, 2014

Oops, just realized I forgot to sign the CLA. I just did that so it should be good now.

@arvindsv
Copy link
Member

arvindsv commented Sep 4, 2014

Thanks @lcs777! I can take a look at it today or tomorrow. If someone else is free before that, please feel free to review and comment.

Should keep #229 in mind, while looking at this.

Copy link
Member

Choose a reason for hiding this comment

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

Small note: User quux is not used in this test and can be removed.

@arvindsv
Copy link
Member

arvindsv commented Sep 5, 2014

@lcs777: I think this is looking good to be merged soon. I had a couple of points. Take a look at them. I really like the test names you've chosen and how everything looks. Thanks!

I've seen it in the UI and I'm running all the tests against this change.

Copy link
Member

Choose a reason for hiding this comment

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

This else is redundant.

@lcs777
Copy link
Contributor Author

lcs777 commented Sep 6, 2014

Great idea about make a NotificationFilter.appliesTo() method. I fixed all of the issues. Hopefully should be good now.

arvindsv added a commit that referenced this pull request Sep 8, 2014
Added feature to allow user to have a wildcard for selecting "Any Pipeli...
@arvindsv arvindsv merged commit b52b1a9 into gocd:master Sep 8, 2014
@arvindsv
Copy link
Member

arvindsv commented Sep 8, 2014

Hi @lcs777,

I've accepted it, but I found that there is a small difference now between appliesTo and matchStage. Here's what I mean:

@Test
public void specificStageShouldMatchWithinAnyPipeline() {
    NotificationFilter filter = new NotificationFilter(GoConstants.ANY_PIPELINE, "dev", StageEvent.Breaks, false);
    assertThat(filter.matchStage(new StageConfigIdentifier("cruise1", "dev"), StageEvent.Breaks), is(true));
    assertThat(filter.matchStage(new StageConfigIdentifier("cruise2", "dev"), StageEvent.Breaks), is(true));
}

@Test
public void specificStageShouldApplyToAnyPipeline() {
    NotificationFilter filter = new NotificationFilter(GoConstants.ANY_PIPELINE, "dev", StageEvent.Breaks, false);
    assertThat(filter.appliesTo("cruise1", "dev"), is(true));
    assertThat(filter.appliesTo("cruise2", "dev"), is(true));
}

The first test (for matchStage) fails and the second test (for appliesTo) passes, given the same condition. The condition that I'm checking is "ANY_PIPELINE" + "Specific stage". I don't know if it makes sense. It might, for someone who uses pedantic names for their stages ("I want to be notified for all 'test' stage failures, across all pipelines").

I don't see why this difference in behavior needs to exist. I think shouldMatch should just call appliesTo. Like this:

public boolean matchStage(StageConfigIdentifier stageIdentifier, StageEvent event) {
    return this.event.include(event) && appliesTo(stageIdentifier.getPipelineName(), stageIdentifier.getStageName());
}

Let me know what you think.

@lcs777
Copy link
Contributor Author

lcs777 commented Sep 8, 2014

I made your changes in my local repo and think it makes perfect sense. Do you want to put the changes in, since you already have the code, or should I make another pull request?

Hopefully I will be a little less sloppy in my next pull request so I will catch that.

thanks,
lcs777

@arvindsv
Copy link
Member

arvindsv commented Sep 8, 2014

Hi,

That's fine. I can make this change.

It's completely ok! That's why code gets seen before merging. So, we can all help each other. If you have comments about any other code that gets in, please feel free to comment. :) I appreciate the commits and the changes.

Cheers,
Aravind

arvindsv added a commit to arvindsv/gocd that referenced this pull request Sep 8, 2014
arvindsv added a commit that referenced this pull request Sep 8, 2014
#466 - Make behaviour of appliesTo and matchStage same.
@arvindsv
Copy link
Member

arvindsv commented Sep 9, 2014

Hey @lcs777,

The build for this is available at http://www.go.cd/download/ (build number 816 or later), if you want to download and check.

Cheers,
Aravind

PS: I just realized that "[Any Pipeline]" and "some-stage" is not going to be allowed from the UI. But, the change is still ok, I feel.

@lcs777
Copy link
Contributor Author

lcs777 commented Sep 9, 2014

Awesome. Hopefully this will mean another instance of Go in a production environment!

Even though it is not currently allowed in the UI, it makes sense to do it anyways. Also, I definitely can see someone doing the "pedantic" naming you suggested and wanting to do what you mentioned in the future.

@arvindsv
Copy link
Member

arvindsv commented Sep 9, 2014

That build is bleeding-edge so to speak. It has gone through all the regression tests, of course. But, be careful. I'd recommend not setting up a production environment on it, yet. 14.3 should come out soon, and that will include this. That release will have gone through more rigorous verification, performance testing, etc. Just saying. :)

I mentioned it is available so that you can take a quick look at the feature you wrote, and see if it looks ok!

@arikagoyal
Copy link
Contributor

Works fine on 14.3.0(1081-da691d74e30a47)

@jeremymv2
Copy link

Is there a way that we could add "Any Pipeline" and "Stage XYZ" ? I have many many pipelines that all use the same template and I have a particular Stage that I want to be notified on. It would be really nice if I could specify one rule that allowed me to match any pipeline but a specific stage, like "QA-Passed".

Are these notifications exposed anywhere that I can manipulate through an API call? If we can't have something like the above Any Pipeline + Specific Stage rule, then maybe I can write something that iterates through all my pipelines and creates new notification rules for each?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants