MR webhook compatibility
This commit is contained in:
parent
88d0f92ad2
commit
89cbe2515d
|
@ -2,6 +2,8 @@ package com.dabsquared.gitlabjenkins.webhook.build;
|
|||
|
||||
import com.dabsquared.gitlabjenkins.GitLabPushTrigger;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestHook;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.ObjectAttributes;
|
||||
import com.dabsquared.gitlabjenkins.gitlab.hook.model.Project;
|
||||
import com.dabsquared.gitlabjenkins.util.JsonUtil;
|
||||
import com.dabsquared.gitlabjenkins.webhook.WebHookAction;
|
||||
import hudson.model.Job;
|
||||
|
@ -29,10 +31,21 @@ public class MergeRequestBuildAction extends BuildWebHookAction {
|
|||
this.mergeRequestHook = JsonUtil.read(json, MergeRequestHook.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Noop for merge request hooks.
|
||||
*/
|
||||
void processForCompatibility() {}
|
||||
void processForCompatibility() {
|
||||
// url and homepage are introduced in 8.x versions of Gitlab
|
||||
final ObjectAttributes attributes = this.mergeRequestHook.getObjectAttributes();
|
||||
if (attributes != null) {
|
||||
final Project source = attributes.getSource();
|
||||
if (source != null && source.getHttpUrl() != null) {
|
||||
if (source.getUrl() == null) {
|
||||
source.setUrl(source.getHttpUrl());
|
||||
}
|
||||
if (source.getHomepage() == null) {
|
||||
source.setHomepage(source.getHttpUrl().substring(0, source.getHttpUrl().lastIndexOf(".git")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
ACL.impersonate(ACL.SYSTEM, new Runnable() {
|
||||
|
|
Loading…
Reference in New Issue