接受pr更新,pr合并触发构建

This commit is contained in:
yashin 2018-06-27 15:57:05 +08:00
parent 56f5600b93
commit d21e0aa338
5 changed files with 8 additions and 15 deletions

View File

@ -4,5 +4,5 @@ package com.dabsquared.gitlabjenkins.gitlab.hook.model;
* @author Robin Müller
*/
public enum Action {
open, update, approved, close
open, update, approved, close, merge
}

View File

@ -101,6 +101,7 @@ public class MergeRequestHook extends WebHook {
.append(user, that.user)
.append(assignee, that.assignee)
.append(project, that.project)
.append(action, that.action)
.append(state, that.state)
.append(objectAttributes, that.objectAttributes)
.append(labels, that.labels)
@ -116,6 +117,7 @@ public class MergeRequestHook extends WebHook {
.append(objectAttributes)
.append(labels)
.append(state)
.append(action)
.toHashCode();
}
@ -126,6 +128,7 @@ public class MergeRequestHook extends WebHook {
.append("assignee", assignee)
.append("project", project)
.append("state", state)
.append("action", action)
.append("objectAttributes", objectAttributes)
.append("labels", labels)
.toString();

View File

@ -28,7 +28,6 @@ public class MergeRequestObjectAttributes {
private String mergeStatus;
private String mergeCommitSha;
private String url;
private Action action;
private Boolean workInProgress;
public Integer getId() {
@ -160,14 +159,6 @@ public class MergeRequestObjectAttributes {
this.url = url;
}
public Action getAction() {
return action;
}
public void setAction(Action action) {
this.action = action;
}
public Boolean getWorkInProgress() {
return workInProgress;
}
@ -199,7 +190,6 @@ public class MergeRequestObjectAttributes {
.append(mergeCommitSha, that.mergeCommitSha)
.append(mergeStatus, that.mergeStatus)
.append(url, that.url)
.append(action, that.action)
.append(workInProgress, that.workInProgress)
.isEquals();
}
@ -220,7 +210,6 @@ public class MergeRequestObjectAttributes {
.append(mergeStatus)
.append(mergeCommitSha)
.append(url)
.append(action)
.append(workInProgress)
.toHashCode();
}
@ -241,7 +230,6 @@ public class MergeRequestObjectAttributes {
.append("mergeCommitSha", mergeCommitSha)
.append("mergeStatus", mergeStatus)
.append("url", url)
.append("action", action)
.append("workInProgress", workInProgress)
.toString();
}

View File

@ -36,6 +36,7 @@ public final class MergeRequestHookTriggerHandlerFactory {
Set<Action> allowedActions = EnumSet.of(Action.open, Action.update);
if (triggerOnApprovedMergeRequest)
allowedActions.add(Action.approved);
allowedActions.add(Action.merge);
return allowedActions;
}
@ -46,6 +47,7 @@ public final class MergeRequestHookTriggerHandlerFactory {
List<State> result = new ArrayList<>();
if (triggerOnMergeRequest) {
result.add(State.opened);
result.add(State.open);
result.add(State.reopened);
}
if (triggerOnAcceptedMergeRequest) {

View File

@ -95,7 +95,7 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
if (!this.cancelPendingBuildsOnUpdate) {
return;
}
if (!hook.getObjectAttributes().getAction().equals(Action.update)) {
if (!hook.getAction().equals(Action.update)) {
return;
}
this.pendingBuildsHandler.cancelPendingBuilds(job, hook.getObjectAttributes().getSourceProjectId(), hook.getObjectAttributes().getSourceBranch());
@ -171,7 +171,7 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
private boolean isLastCommitNotYetBuild(Job<?, ?> project, MergeRequestHook hook) {
MergeRequestObjectAttributes objectAttributes = hook.getObjectAttributes();
if (objectAttributes != null && objectAttributes.getAction() == Action.approved) {
if (objectAttributes != null && hook.getAction() == Action.approved) {
LOGGER.log(Level.FINEST, "Skipping LastCommitNotYetBuild check for approve action");
return true;
}