Search in sources :

Example 1 with CpsScmFlowDefinition

use of org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition in project workflow-job-plugin by jenkinsci.

the class WorkflowJobTest method polling.

@Issue("JENKINS-34716")
@Test
public void polling() throws Exception {
    sampleRepo.init();
    sampleRepo.write("Jenkinsfile", "echo 'first version'");
    sampleRepo.git("add", "Jenkinsfile");
    sampleRepo.git("commit", "-m", "init");
    WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
    p.addTrigger(new SCMTrigger(""));
    p.setDefinition(new CpsScmFlowDefinition(new GitSCM(sampleRepo.toString()), "Jenkinsfile"));
    j.assertLogContains("first version", j.buildAndAssertSuccess(p));
    sampleRepo.write("Jenkinsfile", "echo 'second version'");
    sampleRepo.git("commit", "-a", "-m", "init");
    j.jenkins.setQuietPeriod(0);
    j.createWebClient().getPage(new WebRequest(j.createWebClient().createCrumbedUrl(p.getUrl() + "polling"), HttpMethod.POST));
    j.waitUntilNoActivity();
    WorkflowRun b2 = p.getLastBuild();
    assertEquals(2, b2.getNumber());
    j.assertLogContains("second version", b2);
}
Also used : SCMTrigger(hudson.triggers.SCMTrigger) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) CpsScmFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition) GitSCM(hudson.plugins.git.GitSCM) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Aggregations

WebRequest (com.gargoylesoftware.htmlunit.WebRequest)1 GitSCM (hudson.plugins.git.GitSCM)1 SCMTrigger (hudson.triggers.SCMTrigger)1 CpsScmFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition)1 Test (org.junit.Test)1 Issue (org.jvnet.hudson.test.Issue)1