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);
}
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\""));
}
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);
}
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);
}
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());
}
Aggregations