-
Notifications
You must be signed in to change notification settings - Fork 87
/
GitLabWebHookListener.java
53 lines (43 loc) · 1.72 KB
/
GitLabWebHookListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package io.jenkins.plugins.gitlabbranchsource;
import java.util.logging.Logger;
import jenkins.scm.api.SCMHeadEvent;
import org.gitlab4j.api.webhook.MergeRequestEvent;
import org.gitlab4j.api.webhook.NoteEvent;
import org.gitlab4j.api.webhook.PushEvent;
import org.gitlab4j.api.webhook.TagPushEvent;
import org.gitlab4j.api.webhook.WebHookListener;
public class GitLabWebHookListener implements WebHookListener {
public static final Logger LOGGER = Logger.getLogger(GitLabWebHookListener.class.getName());
private String origin;
public GitLabWebHookListener(String origin) {
this.origin = origin;
}
@Override
public void onNoteEvent(NoteEvent event) {
LOGGER.info("NOTE EVENT");
LOGGER.info(event.toString());
GitLabMergeRequestCommentTrigger trigger = new GitLabMergeRequestCommentTrigger(event);
AbstractGitLabJobTrigger.fireNow(trigger);
}
@Override
public void onMergeRequestEvent(MergeRequestEvent event) {
LOGGER.info("MR EVENT");
LOGGER.info(event.toString());
GitLabMergeRequestSCMEvent trigger = new GitLabMergeRequestSCMEvent(event, origin);
SCMHeadEvent.fireNow(trigger);
}
@Override
public void onPushEvent(PushEvent pushEvent) {
LOGGER.info("PUSH EVENT");
LOGGER.info(pushEvent.toString());
GitLabPushSCMEvent trigger = new GitLabPushSCMEvent(pushEvent, origin);
SCMHeadEvent.fireNow(trigger);
}
@Override
public void onTagPushEvent(TagPushEvent tagPushEvent) {
LOGGER.info("TAG EVENT");
LOGGER.info(tagPushEvent.toString());
GitLabTagPushSCMEvent trigger = new GitLabTagPushSCMEvent(tagPushEvent, origin);
SCMHeadEvent.fireNow(trigger);
}
}