Search in sources :

Example 21 with WorkflowMultiBranchProject

use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.

the class PipelineScmTest method unauthenticatedUserContentUpdateShouldFail.

@Test
public void unauthenticatedUserContentUpdateShouldFail() throws IOException, ExecutionException, InterruptedException {
    WorkflowMultiBranchProject mp = j.createProject(WorkflowMultiBranchProject.class, "mbp");
    mp.setDisplayName("My MBP");
    new RequestBuilder(baseUrl).status(401).data(ImmutableMap.of("content", ImmutableMap.of("data", "Hello World Again!"))).put("/organizations/jenkins/pipelines/mbp/scm/content").build(Map.class);
}
Also used : WorkflowMultiBranchProject(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) Test(org.junit.Test)

Example 22 with WorkflowMultiBranchProject

use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.

the class PipelineScmTest method unauthenticatedUserContentAccessShouldFail.

@Test
public void unauthenticatedUserContentAccessShouldFail() throws IOException, ExecutionException, InterruptedException {
    WorkflowMultiBranchProject mp = j.createProject(WorkflowMultiBranchProject.class, "mbp");
    mp.setDisplayName("My MBP");
    new RequestBuilder(baseUrl).status(401).get("/organizations/jenkins/pipelines/mbp/scm/content").build(Map.class);
}
Also used : WorkflowMultiBranchProject(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) Test(org.junit.Test)

Example 23 with WorkflowMultiBranchProject

use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.

the class JobAnalyticsTest method createMultiBranch.

private void createMultiBranch(GitSampleRepoRule rule) throws Exception {
    WorkflowMultiBranchProject mp = j.createProject(WorkflowMultiBranchProject.class, UUID.randomUUID().toString());
    mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, rule.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0])));
    mp.save();
    mp.scheduleBuild2(0).getFuture().get();
    mp.getIndexing().getLogText().writeLogTo(0, System.out);
    j.waitUntilNoActivity();
    WorkflowJob master = mp.getItemByBranchName("master");
    assertNotNull(master);
    WorkflowRun lastBuild = master.getLastBuild();
    assertNotNull(lastBuild);
    assertEquals(Result.SUCCESS, lastBuild.getResult());
}
Also used : WorkflowMultiBranchProject(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) GitSCMSource(jenkins.plugins.git.GitSCMSource) BranchSource(jenkins.branch.BranchSource) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) DefaultBranchPropertyStrategy(jenkins.branch.DefaultBranchPropertyStrategy) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun)

Example 24 with WorkflowMultiBranchProject

use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.

the class MultiBranchTest method getMultiBranchPipelineRunStages.

@Test
public void getMultiBranchPipelineRunStages() throws Exception {
    WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
    mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0])));
    for (SCMSource source : mp.getSCMSources()) {
        assertEquals(mp, source.getOwner());
    }
    WorkflowJob p = scheduleAndFindBranchProject(mp, "master");
    j.waitUntilNoActivity();
    WorkflowRun b1 = p.getLastBuild();
    assertEquals(1, b1.getNumber());
    assertEquals(3, mp.getItems().size());
    j.waitForCompletion(b1);
    List<Map> nodes = get("/organizations/jenkins/pipelines/p/branches/master/runs/1/nodes", List.class);
    Assert.assertEquals(3, nodes.size());
}
Also used : WorkflowMultiBranchProject(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) GitSCMSource(jenkins.plugins.git.GitSCMSource) SCMSource(jenkins.scm.api.SCMSource) GitSCMSource(jenkins.plugins.git.GitSCMSource) BranchSource(jenkins.branch.BranchSource) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) DefaultBranchPropertyStrategy(jenkins.branch.DefaultBranchPropertyStrategy) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) Test(org.junit.Test)

Example 25 with WorkflowMultiBranchProject

use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.

the class MultiBranchTest method getMultiBranchPipeline.

@Test
public void getMultiBranchPipeline() throws IOException, ExecutionException, InterruptedException {
    Assume.assumeTrue(runAllTests());
    WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
    mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0])));
    for (SCMSource source : mp.getSCMSources()) {
        assertEquals(mp, source.getOwner());
    }
    mp.scheduleBuild2(0).getFuture().get();
    Map resp = get("/organizations/jenkins/pipelines/p/");
    validateMultiBranchPipeline(mp, resp, 3);
    List<String> names = (List<String>) resp.get("branchNames");
    IsArrayContainingInAnyOrder.arrayContainingInAnyOrder(names, branches);
    List<Map> br = get("/organizations/jenkins/pipelines/p/branches", List.class);
    List<String> branchNames = new ArrayList<>();
    List<Integer> weather = new ArrayList<>();
    for (Map b : br) {
        branchNames.add((String) b.get("name"));
        weather.add((int) b.get("weatherScore"));
    }
    for (String n : branches) {
        assertTrue(branchNames.contains(n));
    }
    for (int s : weather) {
        assertEquals(100, s);
    }
}
Also used : ArrayList(java.util.ArrayList) GitSCMSource(jenkins.plugins.git.GitSCMSource) SCMSource(jenkins.scm.api.SCMSource) GitSCMSource(jenkins.plugins.git.GitSCMSource) BranchSource(jenkins.branch.BranchSource) WorkflowMultiBranchProject(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) DefaultBranchPropertyStrategy(jenkins.branch.DefaultBranchPropertyStrategy) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

WorkflowMultiBranchProject (org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject)44 Test (org.junit.Test)38 BranchSource (jenkins.branch.BranchSource)36 GitSCMSource (jenkins.plugins.git.GitSCMSource)36 SCMSource (jenkins.scm.api.SCMSource)32 DefaultBranchPropertyStrategy (jenkins.branch.DefaultBranchPropertyStrategy)31 Map (java.util.Map)28 ImmutableMap (com.google.common.collect.ImmutableMap)26 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)26 List (java.util.List)16 ImmutableList (com.google.common.collect.ImmutableList)15 ArrayList (java.util.ArrayList)13 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)12 User (hudson.model.User)7 Queue (hudson.model.Queue)5 MockFolder (org.jvnet.hudson.test.MockFolder)5 FreeStyleProject (hudson.model.FreeStyleProject)3 Item (hudson.model.Item)3 RunList (hudson.util.RunList)3 Domain (com.cloudbees.plugins.credentials.domains.Domain)2