本文整理匯總了Java中hudson.model.FreeStyleProject.getLastBuild方法的典型用法代碼示例。如果您正苦於以下問題:Java FreeStyleProject.getLastBuild方法的具體用法?Java FreeStyleProject.getLastBuild怎麽用?Java FreeStyleProject.getLastBuild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hudson.model.FreeStyleProject
的用法示例。
在下文中一共展示了FreeStyleProject.getLastBuild方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: testEnvironment
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testEnvironment() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
final String repoName = "cb/jenkins";
project.addTrigger(new DockerHubTrigger(new TriggerOnSpecifiedImageNames(repoName)));
project.getBuildersList().add(new PrintEnvironment());
project.getBuildersList().add(new MockBuilder(Result.SUCCESS));
j.createWebClient().goTo("dockerhub-webhook/debug?image=" + repoName);
j.waitUntilNoActivity();
FreeStyleBuild build = project.getLastBuild();
j.assertLogContains(repoName, build);
j.assertLogContains(DockerHubPushNotification.KEY_REPO_NAME + " = " + repoName, build);
}
示例3: someTest
import hudson.model.FreeStyleProject; //導入方法依賴的package包/類
@LocalData
@Test
public void someTest() throws Exception {
config.getConfigs().add(github.serverConfig());
config.save();
Thread.sleep(1000);
FreeStyleProject prj = jRule.createFreeStyleProject("project");
prj.addProperty(new GithubProjectProperty("http://localhost/org/repo"));
final List<GitHubBranchEvent> events = new ArrayList<>();
events.add(new GitHubBranchCreatedEvent());
events.add(new GitHubBranchHashChangedEvent());
final GitHubBranchTrigger trigger = new GitHubBranchTrigger("", CRON, events);
prj.addTrigger(trigger);
prj.save();
// activate trigger
jRule.configRoundtrip(prj);
final GitHubBranchTrigger branchTrigger = prj.getTrigger(GitHubBranchTrigger.class);
assertThat(branchTrigger.getRemoteRepository(), notNullValue());
GitHubBranchRepository localRepo = prj.getAction(GitHubBranchRepository.class);
assertThat(localRepo, notNullValue());
assertThat(localRepo.getBranches().size(), is(2));
assertThat(localRepo.getBranches(), hasKey("for-removal"));
assertThat(localRepo.getBranches(), hasKey("should-change"));
GitHubBranch shouldChange = localRepo.getBranches().get("should-change");
assertThat(shouldChange.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193ffbb"));
// only single branch should change in local repo
branchTrigger.doRun("should-change");
jRule.waitUntilNoActivity();
assertThat(prj.getBuilds(), hasSize(1));
FreeStyleBuild lastBuild = prj.getLastBuild();
GitHubBranchCause cause = lastBuild.getCause(GitHubBranchCause.class);
assertThat(cause, notNullValue());
assertThat(cause.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193ffgg"));
assertThat(cause.getBranchName(), is("should-change"));
localRepo = prj.getAction(GitHubBranchRepository.class);
assertThat(localRepo, notNullValue());
assertThat(localRepo.getBranches().size(), is(2));
assertThat(localRepo.getBranches(), hasKey("for-removal"));
assertThat(localRepo.getBranches(), hasKey("should-change"));
shouldChange = localRepo.getBranches().get("should-change");
assertThat(shouldChange.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193ffgg"));
// and now full trigger run()
branchTrigger.run();
jRule.waitUntilNoActivity();
assertThat(prj.getBuilds(), hasSize(2));
lastBuild = prj.getLastBuild();
cause = lastBuild.getCause(GitHubBranchCause.class);
assertThat(cause, notNullValue());
assertThat(cause.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193db5e"));
assertThat(cause.getBranchName(), is("new-branch"));
localRepo = prj.getAction(GitHubBranchRepository.class);
assertThat(localRepo.getBranches().size(), is(2));
assertThat(localRepo.getBranches(), not(hasKey("for-removal")));
assertThat(localRepo.getBranches(), hasKey("should-change"));
shouldChange = localRepo.getBranches().get("should-change");
assertThat(shouldChange.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193ffgg"));
assertThat(localRepo.getBranches(), hasKey("new-branch"));
GitHubBranch branch = localRepo.getBranches().get("new-branch");
assertThat(branch.getCommitSha(), is("6dcb09b5b57875f334f61aebed695e2e4193db5e"));
}