Search in sources :

Example 1 with MultiBranchPipeline

use of io.blueocean.ath.model.MultiBranchPipeline in project blueocean-plugin by jenkinsci.

the class GitCreationPage method createPipeline.

public MultiBranchPipeline createPipeline(SSEClientRule sseCLient, String pipelineName, String url, String sshPrivateKey, String user, String pass) throws IOException {
    jobApi.deletePipeline(pipelineName);
    dashboardPage.clickNewPipelineBtn();
    clickGitCreationOption();
    wait.until(By.cssSelector("div.text-repository-url input")).sendKeys(url);
    wait.until(By.cssSelector("button.button-create-credential")).click();
    if (!Strings.isNullOrEmpty(sshPrivateKey)) {
        wait.until(By.xpath("//span[text()='SSH Key']")).click();
        wait.until(By.cssSelector("textarea.TextArea-control")).sendKeys(sshPrivateKey);
        wait.until(By.cssSelector(".Dialog-button-bar button.button-create-credental")).click();
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".create-credential-dialog")));
        logger.info("Created credential");
    } else if (!Strings.isNullOrEmpty(user) && !Strings.isNullOrEmpty(pass)) {
        wait.until(By.xpath("//span[text()='Username & Password']")).click();
        wait.until(By.cssSelector("div.text-username input")).sendKeys(user);
        wait.until(By.cssSelector("div.text-password input")).sendKeys(pass);
        wait.until(By.cssSelector(".Dialog-button-bar button.button-create-credental")).click();
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".create-credential-dialog")));
        logger.info("Created user/pass credential");
    }
    wait.until(By.cssSelector(".button-create-pipeline")).click();
    logger.info("Click create pipeline button");
    MultiBranchPipeline pipeline = multiBranchPipelineFactory.pipeline(pipelineName);
    wait.until(ExpectedConditions.urlContains(pipeline.getUrl() + "/activity"), 30000);
    sseCLient.untilEvents(SSEEvents.activityComplete(pipeline.getName()));
    driver.navigate().refresh();
    pipeline.getActivityPage().checkUrl();
    return pipeline;
}
Also used : MultiBranchPipeline(io.blueocean.ath.model.MultiBranchPipeline)

Example 2 with MultiBranchPipeline

use of io.blueocean.ath.model.MultiBranchPipeline in project blueocean-plugin by jenkinsci.

the class GithubCreationTest method testCreatePullRequest.

/**
 * This test walks through a simple Pull Request flow..
 *
 * -Creates a github repo with a sample Jenkinsfile and follows
 *  the typical create flow
 * -Navigates back to the top level Dashboard page
 * -Creates a PR in the GH repo
 * -Triggers a rescan of the multibranch pipeline
 * -Opens the PR tab to verify that we actually have something there.
 */
@Test
@Retry(3)
public void testCreatePullRequest() throws IOException {
    String branchToCreate = "new-branch";
    String commitMessage = "Add new-file to our repo";
    MultiBranchPipeline pipeline = mbpFactory.pipeline(repo);
    byte[] firstJenkinsfile = "stage('first-build') { echo 'first-build' }".getBytes("UTF-8");
    GHContentUpdateResponse initialUpdateResponse = ghRepository.createContent(firstJenkinsfile, "firstJenkinsfile", "Jenkinsfile", "master");
    ghRepository.createRef(("refs/heads/" + branchToCreate), initialUpdateResponse.getCommit().getSHA1());
    logger.info("Created master and " + branchToCreate + " branches in " + repo);
    ghRepository.createContent("hi there", "newfile", "new-file", branchToCreate);
    creationPage.createPipeline(token, organization, repo);
    dashboardPage.open();
    ghRepository.createPullRequest(commitMessage, branchToCreate, "master", "My first pull request is very exciting.");
    // Fire the rescan.
    pipeline.rescanThisPipeline();
    dashboardPage.clickPipeline(repo);
    ActivityPage activityPage = pipeline.getActivityPage().checkUrl();
    PullRequestsPage pullRequestsPage = activityPage.clickPullRequestsTab();
    pullRequestsPage.clickRunButton("1");
    pullRequestsPage.clickHistoryButton("1");
    // We'll be on the activity page now, pre-filtered to PR-1.
    // Go to the Pull Requests tab one last time.
    activityPage.clickPullRequestsTab();
}
Also used : ActivityPage(io.blueocean.ath.pages.blue.ActivityPage) MultiBranchPipeline(io.blueocean.ath.model.MultiBranchPipeline) GHContentUpdateResponse(org.kohsuke.github.GHContentUpdateResponse) PullRequestsPage(io.blueocean.ath.pages.blue.PullRequestsPage) Retry(io.blueocean.ath.Retry)

Example 3 with MultiBranchPipeline

use of io.blueocean.ath.model.MultiBranchPipeline in project blueocean-plugin by jenkinsci.

the class GitCreationTest method testSSHPrivateRepository.

@Ignore
@Test
public void testSSHPrivateRepository() throws IOException, GitAPIException, URISyntaxException {
    String gitUrl = liveProperties.getProperty("git.ssh.repository");
    String privateKeyFile = liveProperties.getProperty("git.ssh.keyfile");
    String pipelineName = liveProperties.getProperty("git.ssh.pipelineName");
    Assert.assertNotNull(gitUrl);
    Assert.assertNotNull(privateKeyFile);
    Assert.assertNotNull(pipelineName);
    logger.info("PipelineName: " + pipelineName);
    logger.info("git repo - " + gitUrl);
    String key = IOUtils.toString(new FileInputStream(privateKeyFile));
    MultiBranchPipeline pipeline = gitCreationPage.createPipeline(sseClient, pipelineName, gitUrl, key, null, null);
    pipeline.getActivityPage().testNumberRunsComplete(1);
}
Also used : MultiBranchPipeline(io.blueocean.ath.model.MultiBranchPipeline) FileInputStream(java.io.FileInputStream) Ignore(org.junit.Ignore) Test(org.junit.Test) BlueOceanAcceptanceTest(io.blueocean.ath.BlueOceanAcceptanceTest)

Example 4 with MultiBranchPipeline

use of io.blueocean.ath.model.MultiBranchPipeline in project blueocean-plugin by jenkinsci.

the class FolderTest method multiBranchFolderTest.

/**
 * Tests that the activity page works when there are multiple layers of folders, and with funky characters.
 *
 * As long as activity loads run, any other page for this pipeline should load as it uses a shared router.
 */
@Test
public void multiBranchFolderTest() throws GitAPIException, IOException {
    String pipelineName = "FolderTest_multiBranchFolderTest";
    git.writeJenkinsFile(loadJenkinsFile());
    git.addAll();
    git.commit("First");
    git.createBranch("feature/1");
    MultiBranchPipeline p = mbpFactory.pipeline(folder, pipelineName).createPipeline(git);
    client.untilEvents(p.buildsFinished);
    p.getActivityPage().open();
}
Also used : MultiBranchPipeline(io.blueocean.ath.model.MultiBranchPipeline) Test(org.junit.Test) BlueOceanAcceptanceTest(io.blueocean.ath.BlueOceanAcceptanceTest)

Example 5 with MultiBranchPipeline

use of io.blueocean.ath.model.MultiBranchPipeline in project blueocean-plugin by jenkinsci.

the class NavigationTest method testBranchHistory.

/**
 * This test clicks on the history button on a branch, and makes sure that it navigates to the activity page
 * on the correct url.
 */
@Test
public void testBranchHistory() throws IOException, GitAPIException {
    git.writeJenkinsFile(loadJenkinsFile());
    git.addAll();
    git.commit("Added Jenkinsfile");
    git.createBranch("feature/1");
    git.createBranch("feature@2");
    MultiBranchPipeline pipeline = multiBranchPipelineFactory.pipeline(Folder.folders("a folder", "bfolder", "folder"), "NavigationTest_testNavigation");
    pipeline.createPipeline(git);
    dashboardPage.open();
    dashboardPage.clickPipeline(pipeline.getName());
    ActivityPage activityPage = pipeline.getActivityPage().checkUrl();
    BranchPage branchPage = activityPage.clickBranchTab();
    branchPage.clickHistoryButton("feature/1");
    activityPage.open();
    activityPage.getRunRowForBranch("feature@2").click();
    pipeline.getRunDetailsPipelinePage().checkUrl("feature%402", 1);
    pipeline.getRunDetailsPipelinePage().checkBasicDomElements();
}
Also used : ActivityPage(io.blueocean.ath.pages.blue.ActivityPage) MultiBranchPipeline(io.blueocean.ath.model.MultiBranchPipeline) BranchPage(io.blueocean.ath.pages.blue.BranchPage) Test(org.junit.Test) BlueOceanAcceptanceTest(io.blueocean.ath.BlueOceanAcceptanceTest)

Aggregations

MultiBranchPipeline (io.blueocean.ath.model.MultiBranchPipeline)11 Test (org.junit.Test)9 ActivityPage (io.blueocean.ath.pages.blue.ActivityPage)5 BlueOceanAcceptanceTest (io.blueocean.ath.BlueOceanAcceptanceTest)4 BranchPage (io.blueocean.ath.pages.blue.BranchPage)4 WebElement (org.openqa.selenium.WebElement)2 Retry (io.blueocean.ath.Retry)1 PullRequestsPage (io.blueocean.ath.pages.blue.PullRequestsPage)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 URL (java.net.URL)1 Ignore (org.junit.Ignore)1 GHContentUpdateResponse (org.kohsuke.github.GHContentUpdateResponse)1 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)1 Actions (org.openqa.selenium.interactions.Actions)1