use of jenkins.plugins.git.GitStep in project workflow-cps-plugin by jenkinsci.
the class CpsScmFlowDefinitionTest method lightweight.
@Issue({ "JENKINS-33273", "JENKINS-63305" })
@Test
public void lightweight() throws Exception {
sampleRepo.init();
sampleRepo.write("flow.groovy", "echo 'version one'");
sampleRepo.git("add", "flow.groovy");
sampleRepo.git("commit", "--message=init");
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
GitStep step = new GitStep(sampleRepo.toString());
CpsScmFlowDefinition def = new CpsScmFlowDefinition(step.createSCM(), "flow.groovy");
def.setLightweight(true);
TestDurabilityHintProvider provider = Jenkins.get().getExtensionList(TestDurabilityHintProvider.class).get(0);
provider.registerHint("p", FlowDurabilityHint.PERFORMANCE_OPTIMIZED);
p.setDefinition(def);
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
Assert.assertEquals(FlowDurabilityHint.PERFORMANCE_OPTIMIZED, b.getExecution().getDurabilityHint());
r.assertLogNotContains("Cloning the remote Git repository", b);
r.assertLogNotContains("Retrying after 10 seconds", b);
r.assertLogContains("Obtained flow.groovy from git " + sampleRepo, b);
r.assertLogContains("version one", b);
}
use of jenkins.plugins.git.GitStep in project workflow-cps-plugin by jenkinsci.
the class CpsScmFlowDefinitionTest method missingFile.
@Issue("JENKINS-59425")
@Test
public void missingFile() throws Exception {
sampleRepo.init();
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
GitStep step = new GitStep(sampleRepo.toString());
CpsScmFlowDefinition def = new CpsScmFlowDefinition(step.createSCM(), "flow.groovy");
def.setLightweight(true);
p.setDefinition(def);
WorkflowRun b = r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0));
r.assertLogNotContains("Cloning the remote Git repository", b);
r.assertLogNotContains("Retrying after 10 seconds", b);
r.assertLogContains("Unable to find flow.groovy from git " + sampleRepo, b);
}
use of jenkins.plugins.git.GitStep in project workflow-cps-plugin by jenkinsci.
the class CpsScmFlowDefinitionTest method changelogAndPolling.
@Test
public void changelogAndPolling() throws Exception {
sampleRepo.init();
sampleRepo.write("flow.groovy", "echo 'version one'");
sampleRepo.git("add", "flow.groovy");
sampleRepo.git("commit", "--message=init");
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
// no schedule, use notifyCommit only
p.addTrigger(new SCMTrigger(""));
CpsScmFlowDefinition def = new CpsScmFlowDefinition(new GitStep(sampleRepo.toString()).createSCM(), "flow.groovy");
def.setLightweight(false);
p.setDefinition(def);
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
r.assertLogContains("Cloning the remote Git repository", b);
r.assertLogContains("version one", b);
r.assertLogNotContains("Retrying after 10 seconds", b);
sampleRepo.write("flow.groovy", "echo 'version two'");
sampleRepo.git("add", "flow.groovy");
sampleRepo.git("commit", "--message=next");
sampleRepo.notifyCommit(r);
b = p.getLastBuild();
assertEquals(2, b.number);
r.assertLogContains("Fetching changes from the remote Git repository", b);
r.assertLogContains("version two", b);
r.assertLogNotContains("Retrying after 10 seconds", b);
List<ChangeLogSet<? extends ChangeLogSet.Entry>> changeSets = b.getChangeSets();
assertEquals(1, changeSets.size());
ChangeLogSet<? extends ChangeLogSet.Entry> changeSet = changeSets.get(0);
assertEquals(b, changeSet.getRun());
assertEquals("git", changeSet.getKind());
Iterator<? extends ChangeLogSet.Entry> iterator = changeSet.iterator();
assertTrue(iterator.hasNext());
ChangeLogSet.Entry entry = iterator.next();
assertEquals("[flow.groovy]", entry.getAffectedPaths().toString());
assertFalse(iterator.hasNext());
}
Aggregations