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


Java FreeStyleProject.addTrigger方法代碼示例

本文整理匯總了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));
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:20,代碼來源:GHPullRequestSubscriberTest.java

示例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);
}
 
開發者ID:riboseinc,項目名稱:aws-codecommit-trigger-plugin,代碼行數:37,代碼來源:AbstractFreestyleIT.java

示例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()))
                    )
            )
    ));
}
 
開發者ID:jenkinsci,項目名稱:dockerhub-notification-plugin,代碼行數:34,代碼來源:CoordinatorTest.java

示例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());
}
 
開發者ID:jenkinsci,項目名稱:dockerhub-notification-plugin,代碼行數:13,代碼來源:DockerHubWebHookTest.java

示例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);
}
 
開發者ID:jenkinsci,項目名稱:dockerhub-notification-plugin,代碼行數:15,代碼來源:DockerHubWebHookTest.java

示例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);
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:16,代碼來源:GitHubPRTriggerTest.java

示例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));
}
 
開發者ID:bratchenko,項目名稱:jenkins-github-pull-request-comments,代碼行數:34,代碼來源:GhprcIT.java

示例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));
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:14,代碼來源:GHPullRequestSubscriberTest.java

示例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));
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:14,代碼來源:GHPullRequestSubscriberTest.java

示例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));
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:10,代碼來源:GHPullRequestSubscriberTest.java

示例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));
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:10,代碼來源:GHPullRequestSubscriberTest.java

示例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));
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:10,代碼來源:GHPullRequestSubscriberTest.java

示例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));
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:10,代碼來源:GHPullRequestSubscriberTest.java

示例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);
  }
 
開發者ID:bratchenko,項目名稱:jenkins-github-pull-request-comments,代碼行數:40,代碼來源:GhprcRootActionTest.java

示例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);
}
 
開發者ID:bratchenko,項目名稱:jenkins-github-pull-request-comments,代碼行數:30,代碼來源:GhprcIT.java


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