本文整理匯總了Java中hudson.model.FreeStyleProject.save方法的典型用法代碼示例。如果您正苦於以下問題:Java FreeStyleProject.save方法的具體用法?Java FreeStyleProject.save怎麽用?Java FreeStyleProject.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hudson.model.FreeStyleProject
的用法示例。
在下文中一共展示了FreeStyleProject.save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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
示例2: 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
示例3: call
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Override
public Boolean call() throws Throwable {
final Jenkins jenkins = Jenkins.getInstance();
// prepare job
final FreeStyleProject project = jenkins.createProject(FreeStyleProject.class, "freestyle-project");
final Shell env = new Shell("env");
project.getBuildersList().add(env);
project.setAssignedLabel(new LabelAtom(DOCKER_CLOUD_LABEL));
project.save();
LOG.trace("trace test.");
project.scheduleBuild(new TestCause());
// image pull may take time
waitUntilNoActivityUpTo(jenkins, 10 * 60 * 1000);
final FreeStyleBuild lastBuild = project.getLastBuild();
assertThat(lastBuild, not(nullValue()));
assertThat(lastBuild.getResult(), is(Result.SUCCESS));
assertThat(getLog(lastBuild), Matchers.containsString(TEST_VALUE));
assertThat(getLog(lastBuild), Matchers.containsString(CLOUD_ID + "=" + DOCKER_CLOUD_NAME));
return true;
}
示例4: roundTripTest
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
/**
* Perform a round trip test on the Code Coverage configuration builder.
* <p>
* A project is created, configured, submitted / saved, and reloaded where the original configuration is compared against
* the reloaded configuration for equality.
*/
@Test
public void roundTripTest()
{
try
{
FreeStyleProject project = m_jenkinsRule.createFreeStyleProject("TestProject");
CodeCoverageBuilder before = new CodeCoverageBuilder(EXPECTED_CONNECTION_ID, EXPECTED_CREDENTIALS_ID, EXPECTED_ANALYSIS_PROPERTIES_FILEPATH,
EXPECTED_ANALYSIS_PROPERTIES_STRING);
project.getBuildersList().add(before);
// workaround for eclipse compiler Ambiguous method call
project.save();
m_jenkinsRule.jenkins.reload();
FreeStyleProject reloaded = m_jenkinsRule.jenkins.getItemByFullName(project.getFullName(), FreeStyleProject.class);
assertNotNull(reloaded);
CodeCoverageBuilder after = reloaded.getBuildersList().get(CodeCoverageBuilder.class);
assertNotNull(after);
m_jenkinsRule.assertEqualBeans(before, after, "connectionId,credentialsId,analysisPropertiesPath,analysisProperties");
}
catch (Exception e)
{
// Add the print of the stack trace because the exception message is not enough to troubleshoot the root issue. For
// example, if the exception is constructed without a message, you get no information from executing fail().
e.printStackTrace();
fail(e.getMessage());
}
}
示例5: testConfiguration
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void testConfiguration() throws Exception {
RunSelectorParameter expected = new RunSelectorParameter("SELECTOR", new StatusRunSelector(StatusRunSelector.BuildStatus.STABLE), "foo");
FreeStyleProject job = rule.createFreeStyleProject();
job.addProperty(new ParametersDefinitionProperty(expected));
job.save();
job = rule.configRoundtrip(job);
RunSelectorParameter actual = (RunSelectorParameter) job.getProperty(ParametersDefinitionProperty.class).getParameterDefinition("SELECTOR");
rule.assertEqualDataBoundBeans(expected, actual);
}
示例6: roundTripTest
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
/**
* Perform a round trip test on the SCM configuration.
* <p>
* A project is created, configured, submitted / saved, and reloaded where the original configuration is compared against
* the reloaded configuration for equality.
*
* @param jenkinsRule
* the Jenkins rule
* @param scmConfig
* the configuration to perform the round trip on
* @properties ','-separated list of property names that are compared.
*/
public static void roundTripTest(JenkinsRule jenkinsRule, SCM scmConfig, String properties)
{
try
{
FreeStyleProject project = jenkinsRule.createFreeStyleProject("TestProject");
project.setScm(scmConfig);
// workaround for eclipse compiler Ambiguous method call
project.save();
jenkinsRule.jenkins.reload();
FreeStyleProject reloaded = jenkinsRule.jenkins.getItemByFullName(project.getFullName(), FreeStyleProject.class);
assertNotNull(reloaded);
SCM after = (SCM) reloaded.getScm();
assertNotNull(after);
jenkinsRule.assertEqualBeans(scmConfig, after, properties);
}
catch (Exception e)
{
// Add the print of the stack trace because the exception message is not enough to troubleshoot the root issue. For
// example, if the exception is constructed without a message, you get no information from executing fail().
e.printStackTrace();
fail(e.getMessage());
}
}
示例7: testNonDefaultJob
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test public void testNonDefaultJob() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
j.createSlave("abc", null);
project.setAssignedLabel(j.jenkins.getLabel("abc"));
project.save();
assertFalse(checker.executeCheck(project));
}
示例8: testWithAssignedLabel
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test public void testWithAssignedLabel() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
j.createSlave("test",null);
project.setAssignedLabel(j.jenkins.getLabel("test"));
project.save();
assertFalse(checker.executeCheck(project));
}
示例9: testJobWithGradlew
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test public void testJobWithGradlew() throws Exception {
FreeStyleProject project = j.createFreeStyleProject("WithoutGradle");
project.getBuildersList().add(new hudson.tasks.Shell("#!/bin/bash #single line"));
assertFalse(checker.executeCheck(project));
project.delete();
project = j.createFreeStyleProject("WithoutWrapper");
project.getBuildersList().add(new hudson.tasks.Shell("#!/bin/bash\nline1\nline2\nline3\nline4\nline5\nline6"));
project.getBuildersList().add(new hudson.plugins.gradle.Gradle("description","switches","tasks","rootBuildScriptDir","buildFile","gradleName", false, false, false, false));
project.save();
assertTrue(checker.executeCheck(project));
project.delete();
project = j.createFreeStyleProject("WithWrapper");
project.getBuildersList().add(new hudson.plugins.gradle.Gradle("description","switches","tasks","rootBuildScriptDir","buildFile","gradleName", true, false, false, false));
assertFalse(checker.executeCheck(project));
}
示例10: testAbortRunningFreestyleProject
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
@RandomlyFails(value = "No idea why it doesn't work normally")
public void testAbortRunningFreestyleProject() throws Exception {
MockFolder folder = j.createFolder("freestyle_folder");
FreeStyleProject job1 = folder.createProject(FreeStyleProject.class, "project1");
job1.setDisplayName("project1 display name");
job1.setConcurrentBuild(true);
job1.getBuildersList().add(new SleepBuilder());
configRoundTripUnsecure(job1);
job1.save();
FreeStyleProject job2 = folder.createProject(FreeStyleProject.class, "project2");
job2.setDisplayName("project1 display name");
job2.setConcurrentBuild(true);
job2.getBuildersList().add(new SleepBuilder());
configRoundTripUnsecure(job2);
job2.save();
FreeStyleProject job3 = folder.createProject(FreeStyleProject.class, "project3");
job3.setDisplayName("project1 display name");
job3.setConcurrentBuild(true);
job3.getBuildersList().add(new SleepBuilder());
configRoundTripUnsecure(job3);
job3.save();
testAbortRunning(job1, job2, job3);
}
示例11: testWithAssignedLabel
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test public void testWithAssignedLabel() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
project.setAssignedLabel(j.jenkins.getLabel("master"));
project.save();
assertTrue(checker.executeCheck(project));
}
示例12: testDockerShellStep
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void testDockerShellStep() throws Throwable {
jRule.getInstance().setNumExecutors(0);
// jRule.createSlave();
// jRule.createSlave("my-slave", "remote-slave", new EnvVars());
final UsernamePasswordCredentialsImpl credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM,
null, "description", "vagrant", "vagrant");
CredentialsStore store = CredentialsProvider.lookupStores(jRule.getInstance()).iterator().next();
store.addCredentials(Domain.global(), credentials);
final SSHLauncher sshLauncher = new SSHLauncher("192.168.33.10", 22, credentials.getId(),
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", //jvmopts
"", // String javaPath,
"", // String prefixStartSlaveCmd,
"", // String suffixStartSlaveCmd,
20, // Integer launchTimeoutSeconds,
1, // Integer maxNumRetries,
3// Integer retryWaitTime
);
final DumbSlave dumbSlave = new DumbSlave("docker-daemon", "/home/vagrant/jenkins2", sshLauncher);
jRule.getInstance().addNode(dumbSlave);
await().timeout(60, SECONDS).until(() -> assertThat(dumbSlave.getChannel(), notNullValue()));
// String dockerfilePath = dumbSlave.getChannel().call(new DockerBuildImageStepTest.StringThrowableCallable());
final CredentialsYADockerConnector dockerConnector = new CredentialsYADockerConnector()
.withConnectorType(JERSEY)
.withServerUrl("tcp://127.0.0.1:2376")
.withSslConfig(new LocalDirectorySSLConfig("/home/vagrant/keys"));
// .withCredentials(new DockerDaemonFileCredentials(null, "docker-cert", "",
// "/home/vagrant/keys"));
DockerShellStep dockerShellStep = new DockerShellStep();
dockerShellStep.setShellScript("env && pwd");
dockerShellStep.setConnector(dockerConnector);
FreeStyleProject project = jRule.createFreeStyleProject("test");
project.getBuildersList().add(dockerShellStep);
project.save();
QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
FreeStyleBuild freeStyleBuild = taskFuture.get();
jRule.waitForCompletion(freeStyleBuild);
jRule.assertBuildStatusSuccess(freeStyleBuild);
}
示例13: testComboBuild
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Ignore
@Test
public void testComboBuild() throws Throwable {
jRule.getInstance().setNumExecutors(0);
// jRule.createSlave();
// jRule.createSlave("my-slave", "remote-slave", new EnvVars());
final UsernamePasswordCredentialsImpl credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM,
null, "description", "vagrant", "vagrant");
CredentialsStore store = CredentialsProvider.lookupStores(jRule.getInstance()).iterator().next();
store.addCredentials(Domain.global(), credentials);
final SSHLauncher sshLauncher = new SSHLauncher("192.168.33.10", 22, credentials.getId(),
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", //jvmopts
"", // String javaPath,
"", // String prefixStartSlaveCmd,
"", // String suffixStartSlaveCmd,
20, // Integer launchTimeoutSeconds,
1, // Integer maxNumRetries,
3// Integer retryWaitTime
);
final DumbSlave dumbSlave = new DumbSlave("docker-daemon", "/home/vagrant/jenkins2", sshLauncher);
jRule.getInstance().addNode(dumbSlave);
await().timeout(60, SECONDS).until(() -> assertThat(dumbSlave.getChannel(), notNullValue()));
String dockerfilePath = dumbSlave.getChannel().call(new StringThrowableCallable());
final CredentialsYADockerConnector dockerConnector = new CredentialsYADockerConnector()
.withConnectorType(JERSEY)
.withServerUrl("tcp://127.0.0.1:2376")
.withSslConfig(new LocalDirectorySSLConfig("/home/vagrant/keys"));
// .withCredentials(new DockerDaemonFileCredentials(null, "docker-cert", "",
// "/home/vagrant/keys"));
DockerBuildImage buildImage = new DockerBuildImage();
buildImage.setBaseDirectory(dockerfilePath);
buildImage.setPull(true);
buildImage.setTags(Collections.singletonList("localhost:5000/myfirstimage"));
DockerImageComboStep comboStep = new DockerImageComboStep(dockerConnector, buildImage);
comboStep.setClean(true);
comboStep.setPush(true);
FreeStyleProject project = jRule.createFreeStyleProject("test");
project.getBuildersList().add(comboStep);
project.save();
QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
FreeStyleBuild freeStyleBuild = taskFuture.get();
jRule.waitForCompletion(freeStyleBuild);
jRule.assertBuildStatusSuccess(freeStyleBuild);
}
示例14: testBuild
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void testBuild() throws Throwable {
jRule.getInstance().setNumExecutors(0);
// jRule.createSlave();
// jRule.createSlave("my-slave", "remote-slave", new EnvVars());
final UsernamePasswordCredentialsImpl credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM,
null, "description", "vagrant", "vagrant");
CredentialsStore store = CredentialsProvider.lookupStores(jRule.getInstance()).iterator().next();
store.addCredentials(Domain.global(), credentials);
final SSHLauncher sshLauncher = new SSHLauncher("192.168.33.10", 22, credentials.getId(),
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", //jvmopts
"", // String javaPath,
"", // String prefixStartSlaveCmd,
"", // String suffixStartSlaveCmd,
20, // Integer launchTimeoutSeconds,
1, // Integer maxNumRetries,
3// Integer retryWaitTime
);
final DumbSlave dumbSlave = new DumbSlave("docker-daemon", "/home/vagrant/jenkins2", sshLauncher);
jRule.getInstance().addNode(dumbSlave);
await().timeout(60, SECONDS).until(() -> assertThat(dumbSlave.getChannel(), notNullValue()));
String dockerfilePath = dumbSlave.getChannel().call(new StringThrowableCallable());
final CredentialsYADockerConnector dockerConnector = new CredentialsYADockerConnector()
.withConnectorType(JERSEY)
.withServerUrl("tcp://127.0.0.1:2376")
.withSslConfig(new LocalDirectorySSLConfig("/home/vagrant/keys"));
// .withCredentials(new DockerDaemonFileCredentials(null, "docker-cert", "",
// "/home/vagrant/keys"));
DockerBuildImage buildImage = new DockerBuildImage();
buildImage.setBaseDirectory(dockerfilePath);
buildImage.setPull(true);
DockerBuildImageStep dockerBuildImageStep = new DockerBuildImageStep(dockerConnector, buildImage);
FreeStyleProject project = jRule.createFreeStyleProject("test");
project.getBuildersList().add(dockerBuildImageStep);
project.save();
QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
FreeStyleBuild freeStyleBuild = taskFuture.get();
jRule.waitForCompletion(freeStyleBuild);
jRule.assertBuildStatusSuccess(freeStyleBuild);
}
示例15: freestyleTest
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test
public void freestyleTest() throws Exception {
// create job
FreeStyleProject job = jRule.createFreeStyleProject("freestyle-job");
job.addProperty(getPreconfiguredProperty(ghRule.getGhRepo()));
job.addTrigger(getPreconfiguredPRTrigger());
job.getBuildersList().add(new GitHubPRStatusBuilder());
job.getBuildersList().add(new Shell("sleep 10"));
job.getPublishersList().add(new GitHubPRBuildStatusPublisher());
job.getPublishersList().add(new GitHubPRCommentPublisher(new GitHubPRMessage("Comment"), null, null));
job.save();
super.basicTest(job);
}