Java Code Examples for jenkins.scm.api.SCMHeadEvent#fireNow()

The following examples show how to use jenkins.scm.api.SCMHeadEvent#fireNow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HookHandler.java    From gitlab-branch-source-plugin with GNU General Public License v2.0 6 votes vote down vote up
private void handle(String id, GitLabHookEventType eventType, HttpServletRequest request) throws IOException {
    LOGGER.fine("handling hook for " + id + " for eventType " + eventType);
    try {
        String requestBody = getRequestBody(request);
        switch (eventType) {
            case PUSH:
                SCMHeadEvent.fireNow(new GitLabSCMPushEvent(id, readHook(PushHook.class, requestBody), originOf(request)));
                break;
            case TAG_PUSH:
                SCMHeadEvent.fireNow(new GitLabSCMTagPushEvent(id, readHook(PushHook.class, requestBody), originOf(request)));
                break;
            case MERGE_REQUEST:
                argelbargel.jenkins.plugins.gitlab_branch_source.api.Hooks.MergeRequestHook hookAction= readHookTemp(argelbargel.jenkins.plugins.gitlab_branch_source.api.Hooks.MergeRequestHook.class, requestBody);
                SCMHeadEvent.fireNow(GitLabSCMMergeRequestEvent.create(id, readHook(MergeRequestHook.class, requestBody),hookAction.getObjectAttributes().getAction(), originOf(request)));
                break;
            case SYSTEM_HOOK:
                handleSystemHook(id, request,requestBody);
                break;
            default:
                LOGGER.warning("ignoring hook: " + eventType);
                throw new IllegalArgumentException("cannot handle hook-event of type " + eventType);
        }
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "GitLabHookEventType", e);
    }
}
 
Example 2
Source File: GHPRMultiBranchSubscriber.java    From github-integration-plugin with MIT License 6 votes vote down vote up
@Override
protected void onEvent(GHSubscriberEvent event) {
    try {
        GitHub gh = GitHub.offline();

        PullRequestInfo ref = extractPullRequestInfo(event.getGHEvent(), event.getPayload(), gh);
        SCMHeadEvent.fireNow(new GitHubPullRequestScmHeadEvent(
                SCMEvent.Type.UPDATED,
                event.getTimestamp(),
                ref,
                ref.getRepo())
        );

    } catch (Exception e) {
        LOG.error("Can't process {} hook", event, e);
    }
}
 
Example 3
Source File: GHMultiBranchSubscriber.java    From github-integration-plugin with MIT License 6 votes vote down vote up
@Override
protected void onEvent(GHSubscriberEvent event) {
    try {
        BranchInfo ref = extractRefInfo(event.getGHEvent(), event.getPayload(), true);

        if (ref.isTag()) {
            SCMHeadEvent.fireNow(new GitHubTagSCMHeadEvent(
                    SCMEvent.Type.UPDATED,
                    event.getTimestamp(),
                    ref,
                    ref.getRepo())
            );
        } else {
            SCMHeadEvent.fireNow(new GitHubBranchSCMHeadEvent(
                    SCMEvent.Type.UPDATED,
                    event.getTimestamp(),
                    ref,
                    ref.getRepo())
            );
        }

    } catch (Exception e) {
        LOGGER.error("Can't process {} hook", event, e);
    }
}
 
Example 4
Source File: GitLabWebHookListener.java    From gitlab-branch-source-plugin with MIT License 4 votes vote down vote up
@Override
public void onMergeRequestEvent(MergeRequestEvent mrEvent) {
    LOGGER.log(Level.FINE, mrEvent.toString());
    GitLabMergeRequestSCMEvent trigger = new GitLabMergeRequestSCMEvent(mrEvent, origin);
    SCMHeadEvent.fireNow(trigger);
}
 
Example 5
Source File: GitLabWebHookListener.java    From gitlab-branch-source-plugin with MIT License 4 votes vote down vote up
@Override
public void onPushEvent(PushEvent pushEvent) {
    LOGGER.log(Level.FINE, pushEvent.toString());
    GitLabPushSCMEvent trigger = new GitLabPushSCMEvent(pushEvent, origin);
    SCMHeadEvent.fireNow(trigger);
}
 
Example 6
Source File: GitLabWebHookListener.java    From gitlab-branch-source-plugin with MIT License 4 votes vote down vote up
@Override
public void onTagPushEvent(TagPushEvent tagPushEvent) {
    LOGGER.log(Level.FINE, tagPushEvent.toString());
    GitLabTagPushSCMEvent trigger = new GitLabTagPushSCMEvent(tagPushEvent, origin);
    SCMHeadEvent.fireNow(trigger);
}
 
Example 7
Source File: SkipInitialBuildOnFirstBranchIndexingTest.java    From basic-branch-build-strategies-plugin with MIT License 4 votes vote down vote up
private void fire(MockSCMHeadEvent event) throws Exception {
    long watermark = SCMEvents.getWatermark();
    SCMHeadEvent.fireNow(event);
    SCMEvents.awaitAll(watermark);
    j.waitUntilNoActivity();
}
 
Example 8
Source File: GiteaPushSCMEvent.java    From gitea-plugin with MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void process(GiteaPushSCMEvent event) {
    SCMHeadEvent.fireNow(event);
}
 
Example 9
Source File: GiteaCreateSCMEvent.java    From gitea-plugin with MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void process(GiteaCreateSCMEvent event) {
    SCMHeadEvent.fireNow(event);
}
 
Example 10
Source File: GiteaPullSCMEvent.java    From gitea-plugin with MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void process(GiteaPullSCMEvent event) {
    SCMHeadEvent.fireNow(event);
}
 
Example 11
Source File: FreeStyleMultiBranchProjectTest.java    From multi-branch-project-plugin with MIT License 4 votes vote down vote up
private void fire(MockSCMHeadEvent event) throws Exception {
    long watermark = SCMEvents.getWatermark();
    SCMHeadEvent.fireNow(event);
    SCMEvents.awaitAll(watermark);
    r.waitUntilNoActivity();
}