本文整理匯總了Java中hudson.model.FreeStyleProject.addTrigger方法的典型用法代碼示例。如果您正苦於以下問題:Java FreeStyleProject.addTrigger方法的具體用法?Java FreeStyleProject.addTrigger怎麽用?Java FreeStyleProject.addTrigger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hudson.model.FreeStyleProject
的用法示例。
在下文中一共展示了FreeStyleProject.addTrigger方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dontFailOnBadJob
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void dontFailOnBadJob() throws IOException, ANTLRException {
String goodRepo = "https://github.com/KostyaSha-auto/test-repo";
final FreeStyleProject job1 = jenkins.createProject(FreeStyleProject.class, "bad job");
job1.addProperty(new GithubProjectProperty("http://bad.url/deep/bad/path/"));
job1.addTrigger(new GitHubPRTrigger("", GitHubPRTriggerMode.HEAVY_HOOKS_CRON, emptyList()));
Set<Job> jobs = getPRTriggerJobs(goodRepo);
MatcherAssert.assertThat(jobs, hasSize(0));
final FreeStyleProject job2 = jenkins.createProject(FreeStyleProject.class, "good job");
job2.addProperty(new GithubProjectProperty(goodRepo));
job2.addTrigger(new GitHubPRTrigger("", GitHubPRTriggerMode.HEAVY_HOOKS_CRON, emptyList()));
jobs = getPRTriggerJobs("KostyaSha-auto/test-repo");
MatcherAssert.assertThat(jobs, hasSize(1));
MatcherAssert.assertThat(jobs, hasItems(job2));
}
示例2: subscribeProject
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
protected void subscribeProject(final ProjectFixture fixture) throws Exception {
String name = UUID.randomUUID().toString();
final FreeStyleProject job = jenkinsRule.getInstance().createProject(FreeStyleProject.class, name);
job.setScm(new NullSCM());
if (fixture.getScm() != null) {
job.setScm(fixture.getScm());
}
final String uuid = this.sqsQueue.getUuid();
SQSTrigger trigger = null;
if (fixture.isHasTrigger()) {
trigger = new SQSTrigger(uuid, fixture.isSubscribeInternalScm(), fixture.getScmConfigs());
}
final OneShotEvent event = new OneShotEvent();
job.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
event.signal();
fixture.setLastBuild(job.getLastBuild());
return true;
}
});
job.setQuietPeriod(0);
if (trigger != null) {
trigger.start(job, false);
job.addTrigger(trigger);
}
fixture.setEvent(event);
}
示例3: testOneTriggered
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void testOneTriggered() throws Exception {
FreeStyleProject one = j.createFreeStyleProject();
one.addTrigger(new DockerHubTrigger(new TriggerOnSpecifiedImageNames(Arrays.asList("csanchez/jenkins-swarm-slave"))));
one.getBuildersList().add(new MockBuilder(Result.SUCCESS));
JSONObject json = JSONObject.fromObject(IOUtils.toString(getClass().getResourceAsStream("/own-repository-payload.json")));
json.put("callback_url", j.getURL() + "fake-dockerhub/respond");
String url = j.getURL() + DockerHubWebHook.URL_NAME + "/notify";
assertEquals(302, Http.post(url, json));
synchronized (resp) {
resp.wait();
}
JSONObject callback = resp.json;
assertNotNull(callback);
assertEquals("success", callback.getString("state"));
String target_url = callback.getString("target_url");
assertNotNull(target_url);
assertThat(target_url, containsString("/dockerhub-webhook/details/"));
String sha = target_url.substring(target_url.lastIndexOf('/')+1);
TriggerStore.TriggerEntry entry = TriggerStore.getInstance().getEntry(sha);
assertNotNull(entry);
assertThat(entry.getEntries(), allOf(
hasSize(1),
contains(
allOf(
hasProperty("job", sameInstance(one)),
hasProperty("run", sameInstance(one.getLastBuild()))
)
)
));
}
示例4: testDoIndex
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testDoIndex() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
final String repoName = "cb/jenkins";
project.addTrigger(new DockerHubTrigger(new TriggerOnSpecifiedImageNames(repoName)));
project.getBuildersList().add(new MockBuilder(Result.SUCCESS));
j.createWebClient().goTo("dockerhub-webhook/debug?image=" + repoName);
j.waitUntilNoActivity();
j.assertLogContains(repoName, project.getLastBuild());
}
示例5: testEnvironment
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testEnvironment() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
final String repoName = "cb/jenkins";
project.addTrigger(new DockerHubTrigger(new TriggerOnSpecifiedImageNames(repoName)));
project.getBuildersList().add(new PrintEnvironment());
project.getBuildersList().add(new MockBuilder(Result.SUCCESS));
j.createWebClient().goTo("dockerhub-webhook/debug?image=" + repoName);
j.waitUntilNoActivity();
FreeStyleBuild build = project.getLastBuild();
j.assertLogContains(repoName, build);
j.assertLogContains(DockerHubPushNotification.KEY_REPO_NAME + " = " + repoName, build);
}
示例6: checkBuildDataAbsenceAfterBuild
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void checkBuildDataAbsenceAfterBuild() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("test-job");
p.addProperty(new GithubProjectProperty("https://github.com/KostyaSha/test-repo"));
p.addTrigger(defaultGitHubPRTrigger());
p.getBuildersList().add(new BuildDataBuilder());
GitHubPRCause cause = new GitHubPRCause("headSha", 1, true, "targetBranch", "srcBranch", "[email protected]",
"title", new URL("http://www.example.com"), "repoOwner", new HashSet<String>(),
null, false, "nice reason", "author name", "[email protected]", "open");
FreeStyleBuild build = p.scheduleBuild2(0, cause).get();
j.waitUntilNoActivity();
assertTrue(build.getActions(BuildData.class).size() == 0);
}
示例7: shouldNotBuildDisabledBuild
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void shouldNotBuildDisabledBuild() throws Exception {
// GIVEN
FreeStyleProject project = jenkinsRule.createFreeStyleProject("PRJ");
GhprcTrigger trigger = GhprcTestUtil.getTrigger(null);
given(commitPointer.getSha()).willReturn("sha");
GHIssueComment comment = mock(GHIssueComment.class);
given(comment.getBody()).willReturn("retest this please");
given(comment.getUpdatedAt()).willReturn(new DateTime().plusDays(1).toDate());
given(comment.getUser()).willReturn(ghUser);
given(ghPullRequest.getComments()).willReturn(newArrayList(comment));
given(ghPullRequest.getNumber()).willReturn(5);
GhprcTestUtil.setupGhprcTriggerDescriptor(null);
project.addProperty(new GithubProjectProperty("https://github.com/user/dropwizard"));
Ghprc ghprc = spy(trigger.createGhprc(project));
doReturn(ghprcGitHub).when(ghprc).getGitHub();
trigger.start(project, true);
trigger.setHelper(ghprc);
ghprc.getRepository().setHelper(ghprc);
project.addTrigger(trigger);
GitSCM scm = GhprcTestUtil.provideGitSCM();
project.setScm(scm);
project.disable();
GhprcTestUtil.triggerRunAndWait(10, trigger, project);
assertThat(project.getBuilds().toArray().length).isEqualTo(0);
verify(ghRepository, times(0)).createCommitStatus(any(String.class), any(GHCommitState.class), any(String.class), any(String.class));
}
示例8: shouldTriggerJobOnPullRequestOpen
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void shouldTriggerJobOnPullRequestOpen() throws Exception {
when(trigger.getRepoFullName(any(AbstractProject.class))).thenReturn(create(REPO_URL_FROM_PAYLOAD));
when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.HEAVY_HOOKS);
FreeStyleProject job = jenkins.createFreeStyleProject();
job.addProperty(new GithubProjectProperty(REPO_URL_FROM_PAYLOAD));
job.addTrigger(trigger);
new GHPullRequestSubscriber().onEvent(GHEvent.PULL_REQUEST, classpath("payload/pull_request.json"));
verify(trigger).queueRun(eq(job), eq(1));
}
示例9: shouldTriggerFreestyleProjectOnIssueComment
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void shouldTriggerFreestyleProjectOnIssueComment() throws Exception {
when(trigger.getRepoFullName(any(Job.class))).thenReturn(create(REPO_URL_FROM_PAYLOAD));
when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.HEAVY_HOOKS);
FreeStyleProject job = jenkins.createFreeStyleProject();
job.addProperty(new GithubProjectProperty(REPO_URL_FROM_PAYLOAD));
job.addTrigger(trigger);
new GHPullRequestSubscriber().onEvent(GHEvent.ISSUE_COMMENT, classpath("payload/issue_comment.json"));
verify(trigger).queueRun(eq(job), eq(1));
}
示例10: shouldNotBeApplicableWithCronTrigger
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void shouldNotBeApplicableWithCronTrigger() throws Exception {
when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.CRON);
FreeStyleProject job = jenkins.createFreeStyleProject();
job.addTrigger(trigger);
assertThat("should ignore cron trigger", new GHPullRequestSubscriber().isApplicable(job), is(false));
}
示例11: shouldBeApplicableWithHeavyHooksTrigger
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void shouldBeApplicableWithHeavyHooksTrigger() throws Exception {
when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.HEAVY_HOOKS);
FreeStyleProject job = jenkins.createFreeStyleProject();
job.addTrigger(trigger);
assertThat("only for jobs with trigger with hook", new GHPullRequestSubscriber().isApplicable(job), is(true));
}
示例12: shouldBeApplicableWithCronHooksTrigger
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void shouldBeApplicableWithCronHooksTrigger() throws Exception {
when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.HEAVY_HOOKS_CRON);
FreeStyleProject job = jenkins.createFreeStyleProject();
job.addTrigger(trigger);
assertThat("only for jobs with trigger with hook", new GHPullRequestSubscriber().isApplicable(job), is(true));
}
示例13: shouldBeApplicableWithLightHooksTrigger
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void shouldBeApplicableWithLightHooksTrigger() throws Exception {
when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.LIGHT_HOOKS);
FreeStyleProject job = jenkins.createFreeStyleProject();
job.addTrigger(trigger);
assertThat("only for jobs with trigger with hook", new GHPullRequestSubscriber().isApplicable(job), is(true));
}
示例14: testUrlEncoded
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void testUrlEncoded() throws Exception {
// GIVEN
FreeStyleProject project = jenkinsRule.createFreeStyleProject("testUrlEncoded");
GhprcTrigger trigger = spy(GhprcTestUtil.getTrigger(null));
given(commitPointer.getSha()).willReturn("sha1");
GhprcTestUtil.setupGhprcTriggerDescriptor(null);
project.addProperty(new GithubProjectProperty("https://github.com/user/dropwizard"));
given(ghPullRequest.getNumber()).willReturn(1);
Ghprc ghprc = spy(trigger.createGhprc(project));
doReturn(ghprcGitHub).when(ghprc).getGitHub();
trigger.start(project, true);
trigger.setHelper(ghprc);
ghprc.getRepository().setHelper(ghprc);
project.addTrigger(trigger);
GitSCM scm = GhprcTestUtil.provideGitSCM();
project.setScm(scm);
GhprcTestUtil.triggerRunAndWait(10, trigger, project);
assertThat(project.getBuilds().toArray().length).isEqualTo(1);
doReturn(gitHub).when(trigger).getGitHub();
BufferedReader br = new BufferedReader(new StringReader(
"payload=" + URLEncoder.encode(GhprcTestUtil.PAYLOAD, "UTF-8")));
given(req.getContentType()).willReturn("application/x-www-form-urlencoded");
given(req.getParameter("payload")).willReturn(GhprcTestUtil.PAYLOAD);
given(req.getHeader("X-GitHub-Event")).willReturn("issue_comment");
given(req.getReader()).willReturn(br);
given(req.getCharacterEncoding()).willReturn("UTF-8");
GhprcRootAction ra = new GhprcRootAction();
ra.doIndex(req, null);
GhprcTestUtil.waitForBuildsToFinish(project);
assertThat(project.getBuilds().toArray().length).isEqualTo(2);
}
示例15: shouldBuildTriggersOnUpdatingRetestMessagePR
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void shouldBuildTriggersOnUpdatingRetestMessagePR() throws Exception {
// GIVEN
FreeStyleProject project = jenkinsRule.createFreeStyleProject("PRJ");
GhprcTrigger trigger = GhprcTestUtil.getTrigger(null);
given(commitPointer.getSha()).willReturn("sha");
GHIssueComment comment = mock(GHIssueComment.class);
given(comment.getBody()).willReturn("retest this please");
given(comment.getUpdatedAt()).willReturn(new DateTime().plusDays(1).toDate());
given(comment.getUser()).willReturn(ghUser);
given(ghPullRequest.getComments()).willReturn(newArrayList(comment));
given(ghPullRequest.getNumber()).willReturn(5).willReturn(5);
GhprcTestUtil.setupGhprcTriggerDescriptor(null);
project.addProperty(new GithubProjectProperty("https://github.com/user/dropwizard"));
Ghprc ghprc = spy(trigger.createGhprc(project));
doReturn(ghprcGitHub).when(ghprc).getGitHub();
trigger.start(project, true);
trigger.setHelper(ghprc);
ghprc.getRepository().setHelper(ghprc);
project.addTrigger(trigger);
GitSCM scm = GhprcTestUtil.provideGitSCM();
project.setScm(scm);
GhprcTestUtil.triggerRunAndWait(10, trigger, project);
assertThat(project.getBuilds().toArray().length).isEqualTo(2);
}