當前位置: 首頁>>代碼示例>>Java>>正文


Java SCMEvent類代碼示例

本文整理匯總了Java中jenkins.scm.api.SCMEvent的典型用法代碼示例。如果您正苦於以下問題:Java SCMEvent類的具體用法?Java SCMEvent怎麽用?Java SCMEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SCMEvent類屬於jenkins.scm.api包,在下文中一共展示了SCMEvent類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: GiteaWebhookHandler

import jenkins.scm.api.SCMEvent; //導入依賴的package包/類
protected GiteaWebhookHandler(String eventName) {
    this.eventName = eventName;
    Type bt = Types.getBaseClass(getClass(), GiteaWebhookHandler.class);
    if (bt instanceof ParameterizedType) {
        ParameterizedType pt = (ParameterizedType) bt;
        // this 'p' is the closest approximation of P of GiteadSCMEventHandler
        Class e = Types.erasure(pt.getActualTypeArguments()[0]);
        if (!SCMEvent.class.isAssignableFrom(e)) {
            throw new AssertionError(
                    "Could not determine the " + SCMEvent.class + " event class generic parameter of "
                            + getClass() + " best guess was " + e);
        }
        Class p = Types.erasure(pt.getActualTypeArguments()[1]);
        if (!GiteaEvent.class.isAssignableFrom(p)) {
            throw new AssertionError(
                    "Could not determine the " + GiteaEvent.class + " payload class generic parameter of "
                            + getClass() + " best guess was " + p);
        }
        this.eventClass = e;
        this.payloadClass = p;
    } else {
        throw new AssertionError("Type inferrence failure for subclass " + getClass()
                + " of parameterized type " + GiteaWebhookHandler.class
                + ". Use the constructor that takes the Class objects explicitly.");
    }
}
 
開發者ID:jenkinsci,項目名稱:gitea-plugin,代碼行數:27,代碼來源:GiteaWebhookHandler.java

示例2: doPost

import jenkins.scm.api.SCMEvent; //導入依賴的package包/類
public HttpResponse doPost(StaplerRequest request) throws IOException {
    if (!request.getMethod().equals("POST")) {
        return HttpResponses
                .error(HttpServletResponse.SC_BAD_REQUEST,
                        "Only POST requests are supported, this was a " + request.getMethod() + " request");
    }
    if (!"application/json".equals(request.getContentType())) {
        return HttpResponses
                .error(HttpServletResponse.SC_BAD_REQUEST,
                        "Only application/json content is supported, this was " + request.getContentType());
    }
    String type = request.getHeader("X-Gitea-Event");
    if (StringUtils.isBlank(type)) {
        return HttpResponses.error(HttpServletResponse.SC_BAD_REQUEST,
                "Expecting a Gitea event, missing expected X-Gitea-Event header");
    }
    String origin = SCMEvent.originOf(request);
    boolean processed = false;
    for (GiteaWebhookHandler<?, ?> h : ExtensionList.lookup(GiteaWebhookHandler.class)) {
        if (h.matches(type)) {
            h.process(request.getInputStream(), origin);
            processed = true;
        }
    }
    return HttpResponses.plainText(processed ? "Processed" : "Ignored");
}
 
開發者ID:jenkinsci,項目名稱:gitea-plugin,代碼行數:27,代碼來源:GiteaWebhookAction.java

示例3: given_multibranchWithSources_when_matchingEvent_then_branchesAreFoundAndBuilt

import jenkins.scm.api.SCMEvent; //導入依賴的package包/類
@Test
public void given_multibranchWithSources_when_matchingEvent_then_branchesAreFoundAndBuilt() throws Exception {
    try (MockSCMController c = MockSCMController.create()) {
        c.createRepository("foo");
        FreeStyleMultiBranchProject prj = r.jenkins.createProject(FreeStyleMultiBranchProject.class, "foo");
        prj.getSourcesList().add(new BranchSource(new MockSCMSource(null, c, "foo", true, false, false)));
        fire(new MockSCMHeadEvent("given_multibranchWithSources_when_matchingEvent_then_branchesAreFoundAndBuilt", SCMEvent.Type.UPDATED, c, "foo", "master", "junkHash"));
        assertThat("We now have branches",
                prj.getItems(), not(is((Collection<FreeStyleProject>) Collections.<FreeStyleProject>emptyList())));
        FreeStyleProject master = prj.getItem("master");
        assertThat("We now have the master branch", master, notNullValue());
        r.waitUntilNoActivity();
        assertThat("The master branch was built", master.getLastBuild(), notNullValue());
        assertThat("The master branch was built", master.getLastBuild().getNumber(), is(1));
    }
}
 
開發者ID:jenkinsci,項目名稱:multi-branch-project-plugin,代碼行數:17,代碼來源:FreeStyleMultiBranchProjectTest.java

示例4: given_multibranchWithSources_when_accessingDeadBranch_then_branchCanBeDeleted

import jenkins.scm.api.SCMEvent; //導入依賴的package包/類
@Test
public void given_multibranchWithSources_when_accessingDeadBranch_then_branchCanBeDeleted() throws Exception {
    try (MockSCMController c = MockSCMController.create()) {
        c.createRepository("foo");
        FreeStyleMultiBranchProject prj = r.jenkins.createProject(FreeStyleMultiBranchProject.class, "foo");
        prj.getSourcesList().add(new BranchSource(new MockSCMSource(null, c, "foo", true, false, false)));
        prj.scheduleBuild2(0).getFuture().get();
        r.waitUntilNoActivity();
        assertThat("We now have branches",
                prj.getItems(), not(is((Collection<FreeStyleProject>) Collections.<FreeStyleProject>emptyList())));
        FreeStyleProject master = prj.getItem("master");
        assertThat("We now have the master branch", master, notNullValue());
        r.waitUntilNoActivity();
        assertThat("The master branch was built", master.getLastBuild(), notNullValue());
        assumeThat(master.getACL().hasPermission(ACL.SYSTEM, Item.DELETE), is(false));
        c.deleteBranch("foo", "master");
        fire(new MockSCMHeadEvent(
                "given_multibranchWithSources_when_branchRemoved_then_branchProjectIsNotBuildable",
                SCMEvent.Type.REMOVED, c, "foo", "master", "junkHash"));
        r.waitUntilNoActivity();
        assertThat(master.getACL().hasPermission(ACL.SYSTEM, Item.DELETE), is(true));
    }
}
 
開發者ID:jenkinsci,項目名稱:multi-branch-project-plugin,代碼行數:24,代碼來源:FreeStyleMultiBranchProjectTest.java

示例5: given_multibranchWithSources_when_accessingDeadBranch_then_branchCannotBeBuilt

import jenkins.scm.api.SCMEvent; //導入依賴的package包/類
@Test
@Ignore("Currently failing to honour contract of multi-branch projects with respect to dead branches")
public void given_multibranchWithSources_when_accessingDeadBranch_then_branchCannotBeBuilt() throws Exception {
    try (MockSCMController c = MockSCMController.create()) {
        c.createRepository("foo");
        FreeStyleMultiBranchProject prj = r.jenkins.createProject(FreeStyleMultiBranchProject.class, "foo");
        prj.getSourcesList().add(new BranchSource(new MockSCMSource(null, c, "foo", true, false, false)));
        prj.scheduleBuild2(0).getFuture().get();
        r.waitUntilNoActivity();
        assertThat("We now have branches",
                prj.getItems(), not(is((Collection<FreeStyleProject>) Collections.<FreeStyleProject>emptyList())));
        FreeStyleProject master = prj.getItem("master");
        assertThat("We now have the master branch", master, notNullValue());
        r.waitUntilNoActivity();
        assertThat("The master branch was built", master.getLastBuild(), notNullValue());
        assumeThat(master.isBuildable(), is(true));
        c.deleteBranch("foo", "master");
        fire(new MockSCMHeadEvent(
                "given_multibranchWithSources_when_branchRemoved_then_branchProjectIsNotBuildable",
                SCMEvent.Type.REMOVED, c, "foo", "master", "junkHash"));
        r.waitUntilNoActivity();
        assertThat(master.isBuildable(), is(false));
    }
}
 
開發者ID:jenkinsci,項目名稱:multi-branch-project-plugin,代碼行數:25,代碼來源:FreeStyleMultiBranchProjectTest.java


注:本文中的jenkins.scm.api.SCMEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。