本文整理匯總了Java中hudson.model.FreeStyleProject類的典型用法代碼示例。如果您正苦於以下問題:Java FreeStyleProject類的具體用法?Java FreeStyleProject怎麽用?Java FreeStyleProject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FreeStyleProject類屬於hudson.model包,在下文中一共展示了FreeStyleProject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: authenticatedAccess
import hudson.model.FreeStyleProject; //導入依賴的package包/類
/**
*
* @throws Exception
*/
@PresetData(NO_ANONYMOUS_READACCESS)
@Test
public void authenticatedAccess() throws Exception {
final FreeStyleProject project = j.createFreeStyleProject("free");
JenkinsRule.WebClient wc = j.createWebClient();
wc.login("alice", "alice");
try {
// try with wrong job name
wc.goTo("buildStatus/buildIcon?job=dummy");
fail("should fail, because there is no job with this name");
} catch (FailingHttpStatusCodeException x) {
assertEquals(HTTP_NOT_FOUND, x.getStatusCode());
}
wc.goTo("buildStatus/buildIcon?job=free", "image/svg+xml");
j.buildAndAssertSuccess(project);
}
示例2: loggerShouldBeDecorated
import hudson.model.FreeStyleProject; //導入依賴的package包/類
@Test
public void loggerShouldBeDecorated() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
project.getPublishersList().add(new TfsBuildNotifier("http://testurl.com", "tester", Secret.fromString("testpass"), "testProj", "1"));
jenkinsBuild = project.scheduleBuild2(0).get();
OutputStream os = new ByteArrayOutputStream(2048);
OutputStream appender = underTest.decorateLogger(jenkinsBuild, os);
verify(buildFacadeMock, times(1)).startBuild();
verify(buildFacadeMock, times(1)).startAllTaskRecords();
assertNotNull("Did not create a log appender for TFS", appender);
// verify we properly set environments, this tests makeBuildVariables
Map<String,String> env = new HashMap<String, String>();
underTest.makeBuildVariables(jenkinsBuild, env);
assertTrue("Env is empty", env.size() > 0);
assertEquals("build is should be 1", 1, Integer.parseInt(env.get("TfsBuildId" + jenkinsBuild.getId())));
}
示例3: skipDecorateLoggerIfNoNotifier
import hudson.model.FreeStyleProject; //導入依賴的package包/類
@Test
public void skipDecorateLoggerIfNoNotifier() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
jenkinsBuild = project.scheduleBuild2(0).get();
ByteArrayOutputStream os = new ByteArrayOutputStream(2048);
OutputStream appender = underTest.decorateLogger(jenkinsBuild, os);
verify(buildFacadeMock, never()).startBuild();
verify(buildFacadeMock, never()).startAllTaskRecords();
// reference check, not equality check since we should just return without decorating
assertTrue("Created a log appender for TFS without TFS configuration!", os == appender);
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String log = reader.readLine();
assertTrue("Log not displayed on screen", log.indexOf("not configured") > 0);
}
示例4: validAnonymousViewStatusAccess
import hudson.model.FreeStyleProject; //導入依賴的package包/類
/**
*
* @throws Exception
*/
@Test
public void validAnonymousViewStatusAccess() throws Exception {
final SecurityRealm realm = j.createDummySecurityRealm();
j.jenkins.setSecurityRealm(realm);
GlobalMatrixAuthorizationStrategy auth = new GlobalMatrixAuthorizationStrategy();
auth.add(VIEW_STATUS, "anonymous");
j.getInstance().setSecurityRealm(realm);
j.getInstance().setAuthorizationStrategy(auth);
final FreeStyleProject project = j.createFreeStyleProject("free");
JenkinsRule.WebClient wc = j.createWebClient();
try {
// try with wrong job name
wc.goTo("buildStatus/buildIcon?job=dummy");
fail("should fail, because there is no job with this name");
} catch (FailingHttpStatusCodeException x) {
assertEquals(HTTP_NOT_FOUND, x.getStatusCode());
}
wc.goTo("buildStatus/buildIcon?job=free", "image/svg+xml");
j.buildAndAssertSuccess(project);
}
示例5: validAnonymousAccess
import hudson.model.FreeStyleProject; //導入依賴的package包/類
/**
*
* @throws Exception
*/
@PresetData(ANONYMOUS_READONLY)
@Test
public void validAnonymousAccess() throws Exception {
final FreeStyleProject project = j.createFreeStyleProject("free");
JenkinsRule.WebClient wc = j.createWebClient();
try {
// try with wrong job name
wc.goTo("buildStatus/buildIcon?job=dummy");
fail("should fail, because there is no job with this name");
} catch (FailingHttpStatusCodeException x) {
assertEquals(HTTP_NOT_FOUND, x.getStatusCode());
}
// try with correct job name
wc.goTo("buildStatus/buildIcon?job=free", "image/svg+xml");
j.buildAndAssertSuccess(project);
}
示例6: testWorkflow
import hudson.model.FreeStyleProject; //導入依賴的package包/類
/**
* Also applicable for workflow jobs.
*/
@Issue("JENKINS-30357")
@Test
public void testWorkflow() throws Exception {
FreeStyleProject jobToSelect = j.createFreeStyleProject();
Run runToSelect = j.assertBuildStatusSuccess(jobToSelect.scheduleBuild2(0));
WorkflowJob selecter = createWorkflowJob();
ParameterDefinition paramDef = new StringParameterDefinition(
"SELECTOR", "<StatusRunSelector><buildStatus>STABLE</buildStatus></StatusRunSelector>"
);
selecter.addProperty(new ParametersDefinitionProperty(paramDef));
selecter.setDefinition(new CpsFlowDefinition(String.format("" +
"def runWrapper = selectRun job: '%s', " +
" selector: [$class: 'ParameterizedRunSelector', parameterName: '${SELECTOR}'] \n" +
"assert(runWrapper.id == '%s')", jobToSelect.getFullName(), runToSelect.getId())));
j.assertBuildStatusSuccess(selecter.scheduleBuild2(0));
}
示例7: testBrokenParameter
import hudson.model.FreeStyleProject; //導入依賴的package包/類
/**
* Should not cause a fatal error even for a broken selectors.
*/
@Test
public void testBrokenParameter() throws Exception {
FreeStyleProject jobToSelect = j.createFreeStyleProject();
FreeStyleProject selecter = j.createFreeStyleProject();
RunSelector selector = new ParameterizedRunSelector("${SELECTOR}");
Run run = (Run) selecter.scheduleBuild2(
0,
new ParametersAction(
new StringParameterValue("SELECTOR", "<SomeBrokenSelector")
)
).get();
j.assertBuildStatusSuccess(run);
Run selectedRun = selector.select(jobToSelect, new RunSelectorContext(j.jenkins, run, TaskListener.NULL));
assertThat(selectedRun, nullValue());
}
示例8: testUnavailableSelector
import hudson.model.FreeStyleProject; //導入依賴的package包/類
/**
* Should not cause a fatal error even for an unavailable selectors.
*/
@Test
public void testUnavailableSelector() throws Exception {
FreeStyleProject jobToSelect = j.createFreeStyleProject();
FreeStyleProject selecter = j.createFreeStyleProject();
RunSelector selector = new ParameterizedRunSelector("${SELECTOR}");
Run run = (Run) selecter.scheduleBuild2(
0,
new ParametersAction(
new StringParameterValue("SELECTOR", "<NoSuchSelector />")
)
).get();
j.assertBuildStatusSuccess(run);
Run selectedRun = selector.select(jobToSelect, new RunSelectorContext(j.jenkins, run, TaskListener.NULL));
assertThat(selectedRun, nullValue());
}
示例9: testEmptySelector
import hudson.model.FreeStyleProject; //導入依賴的package包/類
/**
* Should not cause a fatal error even for an empty selectors.
*/
@Test
public void testEmptySelector() throws Exception {
FreeStyleProject jobToSelect = j.createFreeStyleProject();
FreeStyleProject selecter = j.createFreeStyleProject();
RunSelector selector = new ParameterizedRunSelector("${SELECTOR}");
Run run = (Run) selecter.scheduleBuild2(
0,
new ParametersAction(
new StringParameterValue("SELECTOR", "")
)
).get();
j.assertBuildStatusSuccess(run);
Run selectedRun = selector.select(jobToSelect, new RunSelectorContext(j.jenkins, run, TaskListener.NULL));
assertThat(selectedRun, nullValue());
}
示例10: testImmediateValue
import hudson.model.FreeStyleProject; //導入依賴的package包/類
/**
* Also accepts immediate value.
*/
@Test
public void testImmediateValue() throws Exception {
// Prepare an artifact to be copied.
FreeStyleProject jobToSelect = j.createFreeStyleProject();
Run runToSelect = j.assertBuildStatusSuccess(jobToSelect.scheduleBuild2(0));
WorkflowJob selecter = createWorkflowJob();
selecter.setDefinition(new CpsFlowDefinition(String.format("" +
"def runWrapper = selectRun job: '%s', " +
" selector: [$class: 'ParameterizedRunSelector', parameterName: '${SELECTOR}'] \n" +
"assert(runWrapper.id == '%s')", jobToSelect.getFullName(), runToSelect.getId())));
j.assertBuildStatusSuccess(selecter.scheduleBuild2(
0,
null,
new ParametersAction(new StringParameterValue(
"SELECTOR", "<StatusRunSelector><buildStatus>STABLE</buildStatus></StatusRunSelector>"
))
));
}
示例11: testVariableExpression
import hudson.model.FreeStyleProject; //導入依賴的package包/類
/**
* Also accepts variable expression.
*/
@Test
public void testVariableExpression() throws Exception {
FreeStyleProject jobToSelect = j.createFreeStyleProject();
Run runToSelect = j.assertBuildStatusSuccess(jobToSelect.scheduleBuild2(0));
FreeStyleProject selecter = j.createFreeStyleProject();
RunSelector selector = new ParameterizedRunSelector("${SELECTOR}");
Run run = j.assertBuildStatusSuccess(selecter.scheduleBuild2(
0,
(Cause) null,
new ParametersAction(new StringParameterValue(
"SELECTOR",
"<StatusRunSelector><buildStatus>STABLE</buildStatus></StatusRunSelector>"
))
));
Run selectedRun = selector.select(jobToSelect, new RunSelectorContext(j.jenkins, run, TaskListener.NULL));
assertThat(selectedRun, is(runToSelect));
}
示例12: shouldGenerateLivingDocumentatation
import hudson.model.FreeStyleProject; //導入依賴的package包/類
@Test
public void shouldGenerateLivingDocumentatation() throws Exception{
//given
FreeStyleProject project = jenkins.createFreeStyleProject("test");
SingleFileSCM scm = new SingleFileSCM("asciidoctor.json",
CucumberLivingDocumentationIT.class.getResource("/json-output/asciidoctor/asciidoctor.json").toURI().toURL());
project.setScm(scm);
CukedoctorPublisher publisher = new CukedoctorPublisher(null, FormatType.HTML, TocType.RIGHT, true, true, "Living Documentation",false,false,false,false,false);
project.getPublishersList().add(publisher);
project.save();
//when
FreeStyleBuild build = jenkins.buildAndAssertSuccess(project);
//then
jenkins.assertLogContains("Format: html" + NEW_LINE + "Toc: right"+NEW_LINE +
"Title: Living Documentation"+NEW_LINE+"Numbered: true"+NEW_LINE +
"Section anchors: true", build);
jenkins.assertLogContains("Found 4 feature(s)...",build);
jenkins.assertLogContains("Documentation generated successfully!",build);
}
開發者ID:jenkinsci,項目名稱:cucumber-living-documentation-plugin,代碼行數:24,代碼來源:CucumberLivingDocumentationIT.java
示例13: shouldGenerateLivingDocumentatationOnSlaveNode
import hudson.model.FreeStyleProject; //導入依賴的package包/類
@Test
public void shouldGenerateLivingDocumentatationOnSlaveNode() throws Exception{
DumbSlave slave = jenkins.createOnlineSlave();
FreeStyleProject project = jenkins.createFreeStyleProject("test");
project.setAssignedNode(slave);
SingleFileSCM scm = new SingleFileSCM("asciidoctor.json",
CucumberLivingDocumentationIT.class.getResource("/json-output/asciidoctor/asciidoctor.json").toURI().toURL());
project.setScm(scm);
CukedoctorPublisher publisher = new CukedoctorPublisher(null, FormatType.HTML, TocType.RIGHT, true, true, "Living Documentation",false,false,false,false,false);
project.getPublishersList().add(publisher);
project.save();
FreeStyleBuild build = jenkins.buildAndAssertSuccess(project);
jenkins.assertLogContains("Format: html" + NEW_LINE + "Toc: right"+NEW_LINE +
"Title: Living Documentation"+NEW_LINE+"Numbered: true"+NEW_LINE +
"Section anchors: true", build);
jenkins.assertLogContains("Found 4 feature(s)...",build);
jenkins.assertLogContains("Documentation generated successfully!",build);
Assert.assertTrue("It should run on slave",build.getBuiltOn().equals(slave));
}
開發者ID:jenkinsci,項目名稱:cucumber-living-documentation-plugin,代碼行數:24,代碼來源:CucumberLivingDocumentationIT.java
示例14: consulWrite
import hudson.model.FreeStyleProject; //導入依賴的package包/類
@Test
public void consulWrite() throws BuilderException {
try {
FreeStyleProject project = jenkinsRule.createFreeStyleProject();
project.getBuildersList().add(new ConsulKVBuilder(ConsulKVBuilderTest.ACL_ID,
ConsulKVBuilderTest.HOST, ConsulKVBuilderTest.KEY,
ConsulKVBuilderTest.VALUE, null, null, RequestMode.WRITE, 30000, 30000, DebugMode.ENABLED, false));
FreeStyleBuild build = project.scheduleBuild2(0).get();
String log = FileUtils.readFileToString(build.getLogFile());
assertThat(log, containsString(ConsulKVBuilderTest.WRITE_TEST_VALUE));
} catch (IOException ioe) {
throw new BuilderException(ConsulKVBuilderTest.IO_EXCEPTION_TEXT, ioe);
} catch (InterruptedException ie) {
throw new BuilderException(ConsulKVBuilderTest.INTERRUPTED_EXCEPTION_TEXT, ie);
} catch (ExecutionException ee) {
throw new BuilderException(ConsulKVBuilderTest.EXECUTION_EXCEPTION_TEXT, ee);
}
}
示例15: consulRead
import hudson.model.FreeStyleProject; //導入依賴的package包/類
@Test
public void consulRead() throws BuilderException {
try {
FreeStyleProject project = jenkinsRule.createFreeStyleProject();
project.getBuildersList().add(new ConsulKVBuilder(null, ConsulKVBuilderTest.HOST, ConsulKVBuilderTest
.KEY, null,
null, ConsulKVBuilderTest.ENV_KEY, RequestMode.READ, 30000,
30000, DebugMode.ENABLED, false));
FreeStyleBuild build = project.scheduleBuild2(0).get();
String log = FileUtils.readFileToString(build.getLogFile());
assertThat(log, containsString(ConsulKVBuilderTest.READ_TEST_VALUE_1));
assertThat(log, containsString(ConsulKVBuilderTest.READ_TEST_VALUE_2));
} catch (IOException ioe) {
throw new BuilderException(ConsulKVBuilderTest.IO_EXCEPTION_TEXT, ioe);
} catch (InterruptedException ie) {
throw new BuilderException(ConsulKVBuilderTest.INTERRUPTED_EXCEPTION_TEXT, ie);
} catch (ExecutionException ee) {
throw new BuilderException(ConsulKVBuilderTest.EXECUTION_EXCEPTION_TEXT, ee);
}
}