Search in sources :

Example 6 with FreeStyleBuild

use of hudson.model.FreeStyleBuild in project blueocean-plugin by jenkinsci.

the class BlueOceanWebURLBuilderTest method test_freestyle.

@Test
public void test_freestyle() throws IOException, ExecutionException, InterruptedException {
    MockFolder folder1 = jenkinsRule.createFolder("folder1");
    MockFolder folder2 = folder1.createProject(MockFolder.class, "folder two with spaces");
    FreeStyleProject freestyleProject = folder2.createProject(FreeStyleProject.class, "freestyle with spaces");
    String blueOceanURL;
    blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(freestyleProject);
    assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Ffreestyle%20with%20spaces", blueOceanURL);
    FreeStyleBuild run = freestyleProject.scheduleBuild2(0).get();
    blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(run);
    assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Ffreestyle%20with%20spaces/detail/freestyle%20with%20spaces/1", blueOceanURL);
}
Also used : FreeStyleBuild(hudson.model.FreeStyleBuild) MockFolder(org.jvnet.hudson.test.MockFolder) FreeStyleProject(hudson.model.FreeStyleProject) Test(org.junit.Test)

Example 7 with FreeStyleBuild

use of hudson.model.FreeStyleBuild in project blueocean-plugin by jenkinsci.

the class StatePreloaderTest method test.

@Test
public void test() throws IOException, ExecutionException, InterruptedException, SAXException {
    // Create a project and run a build on it.
    FreeStyleProject freestyleProject = j.createProject(FreeStyleProject.class, "freestyle");
    FreeStyleBuild run = freestyleProject.scheduleBuild2(0).get();
    j.waitForCompletion(run);
    // Lets request the activity page for that project. The page should
    // contain some prefetched javascript for the pipeline
    // details + the runs on the page
    String projectBlueUrl = j.jenkins.getRootUrl() + BlueOceanWebURLBuilder.toBlueOceanURL(freestyleProject);
    Document doc = Jsoup.connect(projectBlueUrl + "/activity/").get();
    String script = doc.select("head script").toString();
    Assert.assertTrue(script.contains(String.format("setState('prefetchdata.%s',", PipelineStatePreloader.class.getSimpleName())));
    Assert.assertTrue(script.contains(String.format("setState('prefetchdata.%s',", PipelineActivityStatePreloader.class.getSimpleName())));
    Assert.assertTrue(script.contains("\"restUrl\":\"/blue/rest/organizations/jenkins/pipelines/freestyle/activities/?start=0&limit=26\""));
}
Also used : FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Document(org.jsoup.nodes.Document) Test(org.junit.Test) BaseTest(io.jenkins.blueocean.service.embedded.BaseTest)

Example 8 with FreeStyleBuild

use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.

the class PromotionsDslContextExtensionTest method testShouldGenerateTheDefindedComplexJob.

@Test
public void testShouldGenerateTheDefindedComplexJob() throws Exception {
    // Given
    String dsl = FileUtils.readFileToString(new File("src/test/resources/complex-example-dsl.groovy"));
    FreeStyleProject seedJob = createFreeStyleProject();
    seedJob.getBuildersList().add(new ExecuteDslScripts(new ExecuteDslScripts.ScriptLocation(Boolean.TRUE.toString(), null, dsl), false, RemovedJobAction.DELETE));
    // When        
    QueueTaskFuture<FreeStyleBuild> scheduleBuild2 = seedJob.scheduleBuild2(0);
    // Then
    assertBuildStatusSuccess(scheduleBuild2);
}
Also used : ExecuteDslScripts(javaposse.jobdsl.plugin.ExecuteDslScripts) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) File(java.io.File) Test(org.junit.Test)

Example 9 with FreeStyleBuild

use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.

the class PromotionsDslContextExtensionTest method testShouldGenerateTheDefindedJob.

@Test
public void testShouldGenerateTheDefindedJob() throws Exception {
    // Given
    String dsl = FileUtils.readFileToString(new File("src/test/resources/example-dsl.groovy"));
    FreeStyleProject seedJob = createFreeStyleProject();
    seedJob.getBuildersList().add(new ExecuteDslScripts(new ExecuteDslScripts.ScriptLocation(Boolean.TRUE.toString(), null, dsl), false, RemovedJobAction.DELETE));
    // When        
    QueueTaskFuture<FreeStyleBuild> scheduleBuild2 = seedJob.scheduleBuild2(0);
    // Then
    assertBuildStatusSuccess(scheduleBuild2);
}
Also used : ExecuteDslScripts(javaposse.jobdsl.plugin.ExecuteDslScripts) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) File(java.io.File) Test(org.junit.Test)

Example 10 with FreeStyleBuild

use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.

the class PromotedEnvVarTokenMacroTest method testEnvironmentVariableExpansion.

@Test
public void testEnvironmentVariableExpansion() throws Exception {
    // Assemble
    r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
    User u = User.get("foo");
    u.setFullName("Foobar");
    SecurityContextHolder.getContext().setAuthentication(u.impersonate());
    MockFolder parent = r.createFolder("Folder");
    FreeStyleProject project = parent.createProject(FreeStyleProject.class, "Project");
    JobPropertyImpl promotionProperty = new JobPropertyImpl(project);
    PromotionProcess promotionProcess = promotionProperty.addProcess("promo");
    promotionProcess.conditions.clear();
    ManualCondition manualCondition = new ManualCondition();
    manualCondition.getParameterDefinitions().add(new StringParameterDefinition("PROMOTION_PARAM", "defaultValue"));
    promotionProcess.conditions.add(manualCondition);
    Action approvalAction = new ManualCondition.ManualApproval(promotionProcess.getName(), new LinkedList<ParameterValue>());
    TokenMacroExpressionRecorder recorder = new TokenMacroExpressionRecorder("${PROMOTION_ENV,var=\"PROMOTION_PARAM\"}");
    promotionProcess.getBuildSteps().add(recorder);
    // Act & promote
    FreeStyleBuild build = project.scheduleBuild2(0).get();
    build.addAction(approvalAction);
    build.save();
    Promotion promotion = promotionProcess.considerPromotion2(build, Arrays.asList((ParameterValue) new StringParameterValue("PROMOTION_PARAM", "FOO"))).get();
    // Check results
    EnvVars env = promotion.getEnvironment(TaskListener.NULL);
    assertEquals("The PROMOTION_PARAM variable has not been injected", "FOO", env.get("PROMOTION_PARAM"));
    assertEquals("The promotion variable value has not been resolved by the PROMOTION_PARAM macro", "FOO", recorder.getCaptured());
}
Also used : Action(hudson.model.Action) User(hudson.model.User) StringParameterDefinition(hudson.model.StringParameterDefinition) StringParameterValue(hudson.model.StringParameterValue) ParameterValue(hudson.model.ParameterValue) StringParameterValue(hudson.model.StringParameterValue) FreeStyleBuild(hudson.model.FreeStyleBuild) MockFolder(org.jvnet.hudson.test.MockFolder) FreeStyleProject(hudson.model.FreeStyleProject) JobPropertyImpl(hudson.plugins.promoted_builds.JobPropertyImpl) Promotion(hudson.plugins.promoted_builds.Promotion) ManualCondition(hudson.plugins.promoted_builds.conditions.ManualCondition) EnvVars(hudson.EnvVars) PromotionProcess(hudson.plugins.promoted_builds.PromotionProcess) Test(org.junit.Test)

Aggregations

FreeStyleBuild (hudson.model.FreeStyleBuild)42 FreeStyleProject (hudson.model.FreeStyleProject)42 Test (org.junit.Test)25 JobPropertyImpl (hudson.plugins.promoted_builds.JobPropertyImpl)14 PromotionProcess (hudson.plugins.promoted_builds.PromotionProcess)13 Shell (hudson.tasks.Shell)13 Map (java.util.Map)12 ImmutableMap (com.google.common.collect.ImmutableMap)11 PromotedBuildAction (hudson.plugins.promoted_builds.PromotedBuildAction)8 Promotion (hudson.plugins.promoted_builds.Promotion)7 StringParameterDefinition (hudson.model.StringParameterDefinition)6 ManualCondition (hudson.plugins.promoted_builds.conditions.ManualCondition)6 ManualApproval (hudson.plugins.promoted_builds.conditions.ManualCondition.ManualApproval)6 Descriptor (hudson.model.Descriptor)5 ParameterValue (hudson.model.ParameterValue)5 StringParameterValue (hudson.model.StringParameterValue)4 MockFolder (org.jvnet.hudson.test.MockFolder)4 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)3 Project (hudson.model.Project)3 DescriptorImpl (hudson.plugins.promoted_builds.JobPropertyImpl.DescriptorImpl)3