修复:删除,便捷PR的评论,当评论符合正则要求时也触发构建
This commit is contained in:
parent
7290569a7b
commit
5bed460161
|
@ -0,0 +1,8 @@
|
|||
package com.gitee.jenkins.gitee.hook.model;
|
||||
|
||||
/**
|
||||
* @author Yashin Luo
|
||||
*/
|
||||
public enum NoteAction {
|
||||
comment, edited, deleted
|
||||
}
|
|
@ -16,11 +16,19 @@ public class NoteHook extends WebHook {
|
|||
private Project project;
|
||||
private PullRequestObjectAttributes pullRequest;
|
||||
private NoteObjectAttributes comment;
|
||||
private NoteAction action;
|
||||
|
||||
public NoteAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(NoteAction action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
@ -64,6 +72,7 @@ public class NoteHook extends WebHook {
|
|||
NoteHook that = (NoteHook) o;
|
||||
return new EqualsBuilder()
|
||||
.append(user, that.user)
|
||||
.append(action, that.action)
|
||||
.append(project, that.project)
|
||||
.append(comment, that.comment)
|
||||
.append(pullRequest, that.pullRequest)
|
||||
|
@ -74,6 +83,7 @@ public class NoteHook extends WebHook {
|
|||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 37)
|
||||
.append(user)
|
||||
.append(action)
|
||||
.append(project)
|
||||
.append(comment)
|
||||
.append(pullRequest)
|
||||
|
@ -84,6 +94,7 @@ public class NoteHook extends WebHook {
|
|||
public String toString() {
|
||||
return new ToStringBuilder(this)
|
||||
.append("user", user)
|
||||
.append("action", action)
|
||||
.append("project", project)
|
||||
.append("comment", comment)
|
||||
.append("pullRequest", pullRequest)
|
||||
|
|
|
@ -3,9 +3,7 @@ package com.gitee.jenkins.trigger.handler.note;
|
|||
import com.gitee.jenkins.cause.CauseData;
|
||||
import com.gitee.jenkins.gitee.api.GiteeClient;
|
||||
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||
import com.gitee.jenkins.gitee.hook.model.NoteHook;
|
||||
import com.gitee.jenkins.gitee.hook.model.PullRequestHook;
|
||||
import com.gitee.jenkins.gitee.hook.model.PullRequestObjectAttributes;
|
||||
import com.gitee.jenkins.gitee.hook.model.*;
|
||||
import com.gitee.jenkins.publisher.GiteeMessagePublisher;
|
||||
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||
|
@ -15,7 +13,6 @@ import hudson.model.Job;
|
|||
import hudson.plugins.git.GitSCM;
|
||||
import hudson.plugins.git.RevisionParameterAction;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -42,7 +39,7 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
|||
|
||||
@Override
|
||||
public void handle(Job<?, ?> job, NoteHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||
if (isValidTriggerPhrase(hook.getComment().getBody())) {
|
||||
if (isValidTrigger(hook)) {
|
||||
// 若pr不可自动合并则评论至pr
|
||||
PullRequestObjectAttributes objectAttributes = hook.getPullRequest();
|
||||
if (objectAttributes != null && !objectAttributes.isMergeable()) {
|
||||
|
@ -146,6 +143,14 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isValidTrigger(NoteHook hook) {
|
||||
return (isValidTriggerPhrase(hook.getComment().getBody()) && isValidTriggerAction(hook.getAction()));
|
||||
}
|
||||
|
||||
private boolean isValidTriggerAction(NoteAction action) {
|
||||
return action == NoteAction.comment;
|
||||
}
|
||||
|
||||
private boolean isValidTriggerPhrase(String note) {
|
||||
if (StringUtils.isEmpty(this.noteRegex)) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue