本文整理汇总了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.");
}
}
示例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");
}
示例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));
}
}
示例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));
}
}
示例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));
}
}