支持push webhook触发构建
This commit is contained in:
parent
d21e0aa338
commit
6dc5f9de2c
|
@ -20,7 +20,6 @@ public class PushHook extends WebHook {
|
||||||
private String userName;
|
private String userName;
|
||||||
private String userEmail;
|
private String userEmail;
|
||||||
private String userAvatar;
|
private String userAvatar;
|
||||||
private Integer projectId;
|
|
||||||
private Project project;
|
private Project project;
|
||||||
private List<Commit> commits;
|
private List<Commit> commits;
|
||||||
private Integer totalCommitsCount;
|
private Integer totalCommitsCount;
|
||||||
|
@ -82,11 +81,7 @@ public class PushHook extends WebHook {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getProjectId() {
|
public Integer getProjectId() {
|
||||||
return projectId;
|
return getProject().getId();
|
||||||
}
|
|
||||||
|
|
||||||
public void setProjectId(Integer projectId) {
|
|
||||||
this.projectId = projectId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project getProject() {
|
public Project getProject() {
|
||||||
|
@ -97,6 +92,10 @@ public class PushHook extends WebHook {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRepository(Project project) {
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Commit> getCommits() {
|
public List<Commit> getCommits() {
|
||||||
return commits;
|
return commits;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +129,6 @@ public class PushHook extends WebHook {
|
||||||
.append(userName, pushHook.userName)
|
.append(userName, pushHook.userName)
|
||||||
.append(userEmail, pushHook.userEmail)
|
.append(userEmail, pushHook.userEmail)
|
||||||
.append(userAvatar, pushHook.userAvatar)
|
.append(userAvatar, pushHook.userAvatar)
|
||||||
.append(projectId, pushHook.projectId)
|
|
||||||
.append(project, pushHook.project)
|
.append(project, pushHook.project)
|
||||||
.append(commits, pushHook.commits)
|
.append(commits, pushHook.commits)
|
||||||
.append(totalCommitsCount, pushHook.totalCommitsCount)
|
.append(totalCommitsCount, pushHook.totalCommitsCount)
|
||||||
|
@ -147,7 +145,6 @@ public class PushHook extends WebHook {
|
||||||
.append(userName)
|
.append(userName)
|
||||||
.append(userEmail)
|
.append(userEmail)
|
||||||
.append(userAvatar)
|
.append(userAvatar)
|
||||||
.append(projectId)
|
|
||||||
.append(project)
|
.append(project)
|
||||||
.append(commits)
|
.append(commits)
|
||||||
.append(totalCommitsCount)
|
.append(totalCommitsCount)
|
||||||
|
@ -164,7 +161,6 @@ public class PushHook extends WebHook {
|
||||||
.append("userName", userName)
|
.append("userName", userName)
|
||||||
.append("userEmail", userEmail)
|
.append("userEmail", userEmail)
|
||||||
.append("userAvatar", userAvatar)
|
.append("userAvatar", userAvatar)
|
||||||
.append("projectId", projectId)
|
|
||||||
.append("project", project)
|
.append("project", project)
|
||||||
.append("commits", commits)
|
.append("commits", commits)
|
||||||
.append("totalCommitsCount", totalCommitsCount)
|
.append("totalCommitsCount", totalCommitsCount)
|
||||||
|
|
|
@ -11,6 +11,15 @@ public abstract class WebHook {
|
||||||
|
|
||||||
private Repository repository;
|
private Repository repository;
|
||||||
private String objectKind;
|
private String objectKind;
|
||||||
|
private String hookName;
|
||||||
|
|
||||||
|
public String getHookName() {
|
||||||
|
return this.hookName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHookName(String hookName) {
|
||||||
|
this.hookName = hookName;
|
||||||
|
}
|
||||||
|
|
||||||
public String getObjectKind() {
|
public String getObjectKind() {
|
||||||
return objectKind;
|
return objectKind;
|
||||||
|
@ -40,6 +49,7 @@ public abstract class WebHook {
|
||||||
return new EqualsBuilder()
|
return new EqualsBuilder()
|
||||||
.append(repository, webHook.repository)
|
.append(repository, webHook.repository)
|
||||||
.append(objectKind, webHook.objectKind)
|
.append(objectKind, webHook.objectKind)
|
||||||
|
.append(hookName, webHook.hookName)
|
||||||
.isEquals();
|
.isEquals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +57,7 @@ public abstract class WebHook {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return new HashCodeBuilder(17, 37)
|
return new HashCodeBuilder(17, 37)
|
||||||
.append(repository)
|
.append(repository)
|
||||||
|
.append(hookName)
|
||||||
.append(objectKind)
|
.append(objectKind)
|
||||||
.toHashCode();
|
.toHashCode();
|
||||||
}
|
}
|
||||||
|
@ -55,6 +66,7 @@ public abstract class WebHook {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this)
|
return new ToStringBuilder(this)
|
||||||
.append("repository", repository)
|
.append("repository", repository)
|
||||||
|
.append("hookName", hookName)
|
||||||
.append("objectKind", objectKind)
|
.append("objectKind", objectKind)
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,9 @@ class PushHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<PushHook>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CauseData retrieveCauseData(PushHook hook) {
|
protected CauseData retrieveCauseData(PushHook hook) {
|
||||||
CauseData.ActionType actionType = hook.getObjectKind().equals("tag_push") ? CauseData.ActionType.TAG_PUSH : CauseData.ActionType.PUSH;
|
// fixme 判断是否push tag,Gitee 钩子未有相关数据
|
||||||
|
// CauseData.ActionType actionType = hook.getObjectKind().equals("tag_push") ? CauseData.ActionType.TAG_PUSH : CauseData.ActionType.PUSH;
|
||||||
|
CauseData.ActionType actionType = CauseData.ActionType.PUSH;
|
||||||
return causeData()
|
return causeData()
|
||||||
.withActionType(actionType)
|
.withActionType(actionType)
|
||||||
.withSourceProjectId(hook.getProjectId())
|
.withSourceProjectId(hook.getProjectId())
|
||||||
|
@ -51,12 +53,12 @@ class PushHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<PushHook>
|
||||||
.withSourceBranch(getTargetBranch(hook))
|
.withSourceBranch(getTargetBranch(hook))
|
||||||
.withUserName(hook.getUserName())
|
.withUserName(hook.getUserName())
|
||||||
.withUserEmail(hook.getUserEmail())
|
.withUserEmail(hook.getUserEmail())
|
||||||
.withSourceRepoHomepage(hook.getRepository().getHomepage())
|
.withSourceRepoHomepage(hook.getProject().getHomepage())
|
||||||
.withSourceRepoName(hook.getRepository().getName())
|
.withSourceRepoName(hook.getProject().getName())
|
||||||
.withSourceNamespace(hook.getProject().getNamespace())
|
.withSourceNamespace(hook.getProject().getNamespace())
|
||||||
.withSourceRepoUrl(hook.getRepository().getUrl())
|
.withSourceRepoUrl(hook.getProject().getUrl())
|
||||||
.withSourceRepoSshUrl(hook.getRepository().getGitSshUrl())
|
.withSourceRepoSshUrl(hook.getProject().getSshUrl())
|
||||||
.withSourceRepoHttpUrl(hook.getRepository().getGitHttpUrl())
|
.withSourceRepoHttpUrl(hook.getProject().getHttpUrl())
|
||||||
.withMergeRequestTitle("")
|
.withMergeRequestTitle("")
|
||||||
.withMergeRequestDescription("")
|
.withMergeRequestDescription("")
|
||||||
.withMergeRequestId(null)
|
.withMergeRequestId(null)
|
||||||
|
|
Loading…
Reference in New Issue