本文整理汇总了Java中org.jvnet.hudson.test.JenkinsRule.createFreeStyleProject方法的典型用法代码示例。如果您正苦于以下问题:Java JenkinsRule.createFreeStyleProject方法的具体用法?Java JenkinsRule.createFreeStyleProject怎么用?Java JenkinsRule.createFreeStyleProject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jvnet.hudson.test.JenkinsRule
的用法示例。
在下文中一共展示了JenkinsRule.createFreeStyleProject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: givenSearchWhenJobsWithBuildsAreExecutedThenTheyShouldBeSearchable
import org.jvnet.hudson.test.JenkinsRule; //导入方法依赖的package包/类
public static void givenSearchWhenJobsWithBuildsAreExecutedThenTheyShouldBeSearchable(
JenkinsSearchBackend jenkinsSearchBackend, JenkinsRule rule) throws IOException, ExecutionException,
InterruptedException, SAXException, URISyntaxException, TimeoutException {
assertEquals(0, jenkinsSearchBackend.search("echo").suggestions.size());
FreeStyleProject project1 = rule.createFreeStyleProject("project1");
project1.getBuildersList().add(new Shell("echo $BUILD_TAG\n"));
// Building
project1.scheduleBuild2(0).get();
project1.scheduleBuild2(0).get();
project1.scheduleBuild2(0).get();
rule.createFreeStyleProject("project2");
FreeStyleProject project3 = rule.createFreeStyleProject("project3");
project3.getBuildersList().add(new Shell("cat $BUILD_TAG\n"));
assertEquals(3, jenkinsSearchBackend.search("echo").suggestions.size());
rebuildDatabase(jenkinsSearchBackend, rule);
assertEquals(3, jenkinsSearchBackend.search("echo").suggestions.size());
}
示例2: givenSearchWhenIsNewItShouldSupportRebuildFromClean
import org.jvnet.hudson.test.JenkinsRule; //导入方法依赖的package包/类
public static void givenSearchWhenIsNewItShouldSupportRebuildFromClean(JenkinsSearchBackend jenkinsSearchBackend,
JenkinsRule rule) throws IOException, ExecutionException, InterruptedException, SAXException,
URISyntaxException {
try {
assertEquals(0, jenkinsSearchBackend.search("echo").suggestions.size());
rebuildDatabase(jenkinsSearchBackend, rule);
assertEquals(0, jenkinsSearchBackend.search("echo").suggestions.size());
FreeStyleProject project1 = rule.createFreeStyleProject("project1");
project1.getBuildersList().add(new Shell("echo $BUILD_TAG\n"));
// Building
project1.scheduleBuild2(0).get();
project1.scheduleBuild2(0).get();
project1.scheduleBuild2(0).get();
rebuildDatabase(jenkinsSearchBackend, rule);
assertEquals(3, jenkinsSearchBackend.search("echo").suggestions.size());
} catch (Exception e) {
throw new AssertionError(e);
}
}
示例3: configurePretestedIntegrationPlugin
import org.jvnet.hudson.test.JenkinsRule; //导入方法依赖的package包/类
public static FreeStyleProject configurePretestedIntegrationPlugin(JenkinsRule rule, STRATEGY_TYPE type, List<UserRemoteConfig> repoList, String repoName, boolean runOnSlave, String integrationBranch) throws Exception {
FreeStyleProject project = rule.createFreeStyleProject();
if (runOnSlave) {
DumbSlave onlineSlave = rule.createOnlineSlave();
project.setAssignedNode(onlineSlave);
}
List<GitSCMExtension> gitSCMExtensions = new ArrayList<>();
gitSCMExtensions.add(new PretestedIntegrationAsGitPluginExt(type == STRATEGY_TYPE.SQUASH ? new SquashCommitStrategy() : new AccumulatedCommitStrategy(), integrationBranch, repoName));
gitSCMExtensions.add(new PruneStaleBranch());
gitSCMExtensions.add(new CleanCheckout());
project.getPublishersList().add(new PretestedIntegrationPostCheckout());
GitSCM gitSCM = new GitSCM(repoList,
Collections.singletonList(new BranchSpec("*/ready/**")),
false, Collections.<SubmoduleConfig>emptyList(),
null, null, gitSCMExtensions);
project.setScm(gitSCM);
project.save();
return project;
}
示例4: roundTripTest
import org.jvnet.hudson.test.JenkinsRule; //导入方法依赖的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());
}
}
示例5: submitFile
import org.jvnet.hudson.test.JenkinsRule; //导入方法依赖的package包/类
protected void submitFile(JenkinsRule jenkins, String path, String content) throws Exception {
String filename = path.substring(path.lastIndexOf("/") + 1, path.length());
// Create workspace
String client = "manual.ws";
String stream = null;
String line = "LOCAL";
String view = path + " //" + client + "/" + filename;
WorkspaceSpec spec = new WorkspaceSpec(true, true, false, false, false, false, stream, line, view);
ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("none", true, client, spec);
// Populate with P4 scm
Populate populate = new AutoCleanImpl();
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
// Freestyle job
FreeStyleProject project = jenkins.createFreeStyleProject();
project.setScm(scm);
// Create artifact files
project.getBuildersList().add(new CreateArtifact(filename, content));
// Submit artifacts
SubmitImpl submit = new SubmitImpl("publish", true, true, true, "3");
PublishNotifier publish = new PublishNotifier(CREDENTIAL, workspace, submit);
project.getPublishersList().add(publish);
project.save();
// Start build
Cause.UserIdCause cause = new Cause.UserIdCause();
FreeStyleBuild build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例6: commitFile
import org.jvnet.hudson.test.JenkinsRule; //导入方法依赖的package包/类
protected void commitFile(JenkinsRule jenkins, String path, String content) throws Exception {
String filename = path.substring(path.lastIndexOf("/") + 1, path.length());
// Create workspace
String client = "graphCommit.ws";
String stream = null;
String line = "LOCAL";
String view = path + " //" + client + "/" + filename;
WorkspaceSpec spec = new WorkspaceSpec(true, true, false, false, false, false, stream, line, view, null, "graph", null, true);
ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("none", true, client, spec);
// Populate with P4 scm
Populate populate = new GraphHybridImpl(false, null, null);
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
// Freestyle job
FreeStyleProject project = jenkins.createFreeStyleProject();
project.setScm(scm);
// Create artifact files
project.getBuildersList().add(new CreateArtifact(filename, content));
// Submit artifacts
CommitImpl commit = new CommitImpl("publish", true, true);
commit.addFile(path);
PublishNotifier publish = new PublishNotifier(CREDENTIAL, workspace, commit);
project.getPublishersList().add(publish);
project.save();
// Start build
Cause.UserIdCause cause = new Cause.UserIdCause();
FreeStyleBuild build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例7: executionTest
import org.jvnet.hudson.test.JenkinsRule; //导入方法依赖的package包/类
/**
* Tests the results of a SCM download execution.
* <p>
* A project is created, configured and executed where the log is examined to verify results.
*
* @param jenkinsRule
* the Jenkins rule
* @param scmConfig
* the SCM configuration
*/
public static void executionTest(JenkinsRule jenkinsRule, CpwrScmConfiguration scmConfig)
{
try
{
FreeStyleProject project = jenkinsRule.createFreeStyleProject("TestProject");
project.setScm(scmConfig);
// don't expect the build to succeed since no CLI exists
if (project.scheduleBuild(null))
{
while (project.getLastCompletedBuild() == null)
{
// wait for the build to complete before obtaining the log
continue;
}
FreeStyleBuild build = project.getLastCompletedBuild();
String logFileOutput = JenkinsRule.getLog(build);
String expectedConnectionStr = String.format("Host connection = %s:%s", TestConstants.EXPECTED_HOST,
TestConstants.EXPECTED_PORT);
assertThat("Expected log to contain Host connection: " + expectedConnectionStr + '.', logFileOutput,
containsString(expectedConnectionStr));
String expectedCredentialsStr = String.format("Username = %s", TestConstants.EXPECTED_USER_ID);
assertThat("Expected log to contain Login credentials: " + expectedCredentialsStr + '.', logFileOutput,
containsString(expectedCredentialsStr));
String expectedFilterPatternStr = String.format("Filter pattern = %s", TestConstants.EXPECTED_FILTER_PATTERN);
assertThat("Expected log to contain filter pattern: " + expectedFilterPatternStr + '.', logFileOutput,
containsString(expectedFilterPatternStr));
String expectedFileExtensionStr = String.format("File extension = %s", TestConstants.EXPECTED_FILE_EXTENSION);
assertThat("Expected log to contain file extension: " + expectedFileExtensionStr + '.', logFileOutput,
containsString(expectedFileExtensionStr));
}
}
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());
}
}