Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-40059] CommentAdded trigger firing on every comment
The CommentAdded trigger was firing on any comment after
the necessary value of an approval had been met.
This was happening due to that in previous versions of gerrit
before 2.13.0 approval information only appeared once
something had changed.
This changed to use the oldValue that would optionally
be included on state change. The logic added
to the gerrit-trigger-plugin was based on an earlier
patchset that had an ever present variable for state
change.
This led to a fall through to the old style of checking
for whether to trigger based on a comment.
  • Loading branch information
Tyrone Abdy committed Nov 29, 2016
1 parent ebc8cf6 commit 0a8e1c2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Expand Up @@ -1036,14 +1036,18 @@ private boolean isServerInteresting(GerritTriggeredEvent event) {
* Gerrit stream events changed to append approval info to
* every comment-added event.
**/
if (approval.isUpdated()
&& approval.getType().equals(
commentAdded.getVerdictCategory())
&& (approval.getValue().equals(
commentAdded.getCommentAddedTriggerApprovalValue())
|| ("+" + approval.getValue()).equals(
commentAdded.getCommentAddedTriggerApprovalValue()))) {
return true;
if (GerritVersionChecker.isCorrectVersion(
GerritVersionChecker.Feature.commentAlwaysApproval,
serverName)) {
if (approval.isUpdated()
&& approval.getType().equals(
commentAdded.getVerdictCategory())
&& (approval.getValue().equals(
commentAdded.getCommentAddedTriggerApprovalValue())
|| ("+" + approval.getValue()).equals(
commentAdded.getCommentAddedTriggerApprovalValue()))) {
return true;
}
} else {
if (approval.getType().equals(
commentAdded.getVerdictCategory())
Expand Down
Expand Up @@ -60,7 +60,13 @@ public static enum Feature {
/**
* Project created events, added in Gerrit 2.12.
*/
projectCreatedEvents("Project created events", "2.12");
projectCreatedEvents("Project created events", "2.12"),


/**
* Gerrit CommentAdded always contains approval information, added in Gerrit 2.13.
*/
commentAlwaysApproval("CommentAdded always contains approval", "2.13");

private final String displayName;
private final String version;
Expand Down

0 comments on commit 0a8e1c2

Please sign in to comment.