本文整理汇总了Java中hudson.util.RunList类的典型用法代码示例。如果您正苦于以下问题:Java RunList类的具体用法?Java RunList怎么用?Java RunList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RunList类属于hudson.util包,在下文中一共展示了RunList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createJobMetricsDTO
import hudson.util.RunList; //导入依赖的package包/类
public static JobMetricDTO createJobMetricsDTO(Job job) {
if (job != null) {
JobMetricDTO answer = new JobMetricDTO(job.getDisplayName(), job.getUrl(), job.getEstimatedDuration(), job.isBuilding());
RunList<Run> builds = job.getBuilds();
if (builds != null) {
for (Run build : builds) {
if (Runs.includeBuildInMetrics(build)) {
BuildMetricsDTO buildDto = BuildMetricsDTO.createBuildMetricsDTO(build);
if (buildDto != null) {
answer.addBuild(buildDto);
}
}
}
}
return answer;
}
return null;
}
示例2: testBuilds
import hudson.util.RunList; //导入依赖的package包/类
@Test
@LocalData
public void testBuilds() {
FreeStyleProject job = j.jenkins.getItemByFullName("JenkinsSlaveTrigger", FreeStyleProject.class);
assertNotNull("The job should be loaded", job);
RunList<FreeStyleBuild> builds = job.getBuilds();
FreeStyleBuild two = builds.getLastBuild();
assertNotNull(two);
FreeStyleBuild one = two.getPreviousBuild();
assertNotNull(one);
assertSame("First build should be failure", Result.FAILURE, one.getResult());
assertSame("Second build should be success", Result.SUCCESS, two.getResult());
DockerHubWebHookCause cause = two.getCause(DockerHubWebHookCause.class);
assertNotNull("The cause should be loaded", cause);
PushNotification notification = cause.getPushNotification();
assertNotNull("The cause should have a notification", notification);
assertEquals("csanchez/jenkins-swarm-slave", notification.getRepoName());
assertEquals("registry.hub.example.com", notification.getRegistryHost());
}
示例3: getAllPrBuilds
import hudson.util.RunList; //导入依赖的package包/类
/**
* Searches for all builds performed in the runs of current job.
*
* @return map with keys - numbers of built PRs and values - lists of related builds.
*/
@Nonnull
public Map<Integer, List<Run<?, ?>>> getAllPrBuilds() {
Map<Integer, List<Run<?, ?>>> map = new HashMap<>();
final RunList<?> runs = job.getBuilds();
LOG.debug("Got builds for job {}", job.getFullName());
for (Run<?, ?> run : runs) {
GitHubPRCause cause = ghPRCauseFromRun(run);
if (cause != null) {
int number = cause.getNumber();
List<Run<?, ?>> buildsByNumber = map.get(number);
if (isNull(buildsByNumber)) {
buildsByNumber = new ArrayList<>();
map.put(number, buildsByNumber);
}
buildsByNumber.add(run);
}
}
return map;
}
示例4: getAllBranchBuilds
import hudson.util.RunList; //导入依赖的package包/类
/**
* Searches for all builds performed in the runs of current job.
*
* @return map with key - string branch names; value - lists of related builds.
*/
public Map<String, List<Run<?, ?>>> getAllBranchBuilds() {
Map<String, List<Run<?, ?>>> map = new HashMap<>();
final RunList<?> runs = job.getBuilds();
LOG.debug("Got builds for job {}", job.getFullName());
for (Run<?, ?> run : runs) {
GitHubBranchCause cause = ghBranchCauseFromRun(run);
if (cause != null) {
String branchName = cause.getBranchName();
List<Run<?, ?>> buildsByBranchName = map.get(branchName);
if (isNull(buildsByBranchName)) {
buildsByBranchName = new ArrayList<>();
map.put(branchName, buildsByBranchName);
}
buildsByBranchName.add(run);
}
}
return map;
}
示例5: createProject
import hudson.util.RunList; //导入依赖的package包/类
private AbstractProject<?,?> createProject(String... shas) {
AbstractBuild build = mock(AbstractBuild.class);
List<BuildData> buildDatas = new ArrayList<BuildData>();
for(String sha : shas) {
BuildData buildData = createBuildData(sha);
buildDatas.add(buildData);
}
when(build.getAction(BuildData.class)).thenReturn(buildDatas.get(0));
when(build.getActions(BuildData.class)).thenReturn(buildDatas);
AbstractProject<?, ?> project = mock(AbstractProject.class);
when(build.getProject()).thenReturn(project);
RunList list = mock(RunList.class);
when(list.iterator()).thenReturn(Arrays.asList(build).iterator());
when(project.getBuilds()).thenReturn(list);
return project;
}
示例6: build
import hudson.util.RunList; //导入依赖的package包/类
public static JobResults build(final Job job) {
JobResults jobResults = new JobResults();
final RunList<?> jobs = job.getBuilds();
int jobCount = 0;
for (Run<?,?> jobRun : jobs) {
if (jobCount > 9) break;
if (jobRun.isBuilding()) continue;
TestResultAction testResults = jobRun.getAction(TestResultAction.class);
if (testResults == null) continue;
jobCount++;
final Collection<PackageResult> packageResults = testResults.getResult().getChildren();
for (PackageResult packageResult : packageResults) {
final Collection<ClassResult> classResults = packageResult.getChildren();
for (ClassResult classResult : classResults) {
jobResults.addResult(jobRun, classResult);
}
}
}
return jobResults;
}
示例7: twoFeatureBranchesBothValid_2BuildsAreTriggeredBothBranchesGetIntegratedBuildMarkedAsSUCCESS
import hudson.util.RunList; //导入依赖的package包/类
@Test
public void twoFeatureBranchesBothValid_2BuildsAreTriggeredBothBranchesGetIntegratedBuildMarkedAsSUCCESS() throws Exception {
Repository repository = TestUtilsFactory.createValidRepositoryWith2FeatureBranches("test-repo");
repositories.add(repository);
final int COMMIT_COUNT_BEFORE_EXECUTION = TestUtilsFactory.countCommits(repository);
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, STRATEGY_TYPE.SQUASH, repository);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
RunList<FreeStyleBuild> builds = project.getBuilds();
assertEquals(2, project.getNextBuildNumber() - 1);
for (FreeStyleBuild build : builds) {
Result result = build.getResult();
assertTrue(result.isBetterOrEqualTo(Result.SUCCESS));
}
final int COMMIT_COUNT_AFTER_EXECUTION = TestUtilsFactory.countCommits(repository);
TestCase.assertEquals("Commit count missmatch.", COMMIT_COUNT_AFTER_EXECUTION, COMMIT_COUNT_BEFORE_EXECUTION + 2);
}
示例8: getJobStats
import hudson.util.RunList; //导入依赖的package包/类
/**
* Return information about the latest builds run on each environment/workflow combination
* Called from jelly view
*/
public List<Stat> getJobStats() {
RunList<B> builds = getBuilds();
List<Stat> stats = StatsHelper.getLastStats(builds);
Collections.sort(stats, new Comparator<Stat>() {
@Override
public int compare(Stat o1, Stat o2) {
int result = o1.env.compareTo(o2.env);
if (result == 0) {
result = o2.timestamp.compareTo(o1.timestamp);
}
return result;
}
});
return stats;
}
示例9: getAllStats
import hudson.util.RunList; //导入依赖的package包/类
public static List<Stat> getAllStats(RunList builds) {
Iterator it = builds.iterator();
List<Stat> stats = new ArrayList<Stat>();
while (it.hasNext()) {
AbstractBuild b = (AbstractBuild) it.next();
if (!b.isBuilding() && !b.hasntStartedYet() && b.getResult().isCompleteBuild()) {
Stat stat = new Stat();
stat.buildNumber = String.valueOf(b.getNumber());
stat.artifactsLink = stat.buildNumber + "/artifact/";
stat.deployer = getDeployer(b);
stat.env = getEnv(b);
stat.workflow = getWorkflow(b);
stat.timestampString = b.getTimestampString2();
stat.timestamp = b.getTimestamp();
stat.resultIcon = getStatusImage(b);
stat.console = stat.buildNumber + "/console";
if (!StringUtils.isEmpty(stat.env) && !StringUtils.isEmpty(stat.workflow)) {
stats.add(stat);
}
}
}
return stats;
}
示例10: getLastStats
import hudson.util.RunList; //导入依赖的package包/类
/**
* This method selects the latest build for each env/workflow combination,
* and return the list of statistics for these builds.
* @param builds
* @return
*/
public static List<Stat> getLastStats(RunList builds) {
List<Stat> allStats = getAllStats(builds);
Map<String, Stat> latestStatMap = new HashMap<String, Stat>();
for (Stat s : allStats) {
String key = s.env + "%delim%" + s.workflow;
Stat latest = latestStatMap.get(key);
if (latest == null) {
latestStatMap.put(key, s);
} else {
if (latest.timestamp.before(s.timestamp)) {
latestStatMap.put(key, s);
}
}
}
return new ArrayList<Stat>(latestStatMap.values());
}
示例11: getFirstUpstreamBuild
import hudson.util.RunList; //导入依赖的package包/类
@CheckForNull
private AbstractBuild getFirstUpstreamBuild(AbstractProject<?, ?> project, AbstractProject<?, ?> first,
Result minResult) {
RunList<? extends AbstractBuild> builds = project.getBuilds();
for (AbstractBuild build : builds) {
if (minResult != null && (build.isBuilding() || build.getResult().isWorseThan(minResult))) {
continue;
}
AbstractBuild upstream = BuildUtil.getFirstUpstreamBuild(build, first);
if (upstream != null && upstream.getProject().equals(first)) {
return upstream;
}
}
return null;
}
示例12: triggerManual
import hudson.util.RunList; //导入依赖的package包/类
@Override
public void triggerManual(String projectName, String upstreamName, String buildId)
throws TriggerException, AuthenticationException {
LOG.fine("Manual/Input step called for project: " + projectName + " and build id: " + buildId);
WorkflowJob workflowJob;
try {
workflowJob = ProjectUtil.getWorkflowJob(projectName, getOwnerItemGroup());
RunList<WorkflowRun> builds = workflowJob.getBuilds();
for (WorkflowRun run : builds) {
if (Integer.toString(run.getNumber()).equals(buildId)) {
InputAction inputAction = run.getAction(InputAction.class);
if (inputAction != null && !inputAction.getExecutions().isEmpty()) {
inputAction.getExecutions().get(0).doProceedEmpty();
}
}
}
throw new PipelineException("Failed to resolve manual/input step for build with id: "
+ buildId + " for project: " + projectName);
} catch (IOException | PipelineException e) {
LOG.warning("Failed to resolve project to trigger manual/input step for: " + e);
}
}
示例13: preCheckout
import hudson.util.RunList; //导入依赖的package包/类
/**
* Abort running builds when new build referencing same revision is scheduled to run
*/
@Override
public void preCheckout(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException,
InterruptedException {
String abortOnRevisionId = getAbortOnRevisionId(build);
// If ABORT_ON_REVISION_ID is available
if (!CommonUtils.isBlank(abortOnRevisionId)) {
// Create a cause of interruption
PhabricatorCauseOfInterruption causeOfInterruption =
new PhabricatorCauseOfInterruption(build.getUrl());
Run upstreamRun = getUpstreamRun(build);
// Get the running builds that were scheduled before the current one
RunList<AbstractBuild> runningBuilds = (RunList<AbstractBuild>) build.getProject().getBuilds();
for (AbstractBuild runningBuild : runningBuilds) {
Executor executor = runningBuild.getExecutor();
Run runningBuildUpstreamRun = getUpstreamRun(runningBuild);
// Ignore builds that were triggered by the same upstream build
// Find builds triggered with the same ABORT_ON_REVISION_ID_FIELD
if (runningBuild.isBuilding()
&& runningBuild.number < build.number
&& abortOnRevisionId.equals(getAbortOnRevisionId(runningBuild))
&& (upstreamRun == null
|| runningBuildUpstreamRun == null
|| !upstreamRun.equals(runningBuildUpstreamRun))
&& executor != null) {
// Abort the builds
executor.interrupt(Result.ABORTED, causeOfInterruption);
}
}
}
}
示例14: getBuildsByEnvironment
import hudson.util.RunList; //导入依赖的package包/类
@JavaScriptMethod
public List<Stat> getBuildsByEnvironment(String env) {
RunList<B> builds = getBuilds();
if (env == null) {
env = "null";
}
List<Stat> stats = StatsHelper.getBuildsByEnvironment(builds, env);
Collections.sort(stats, new Comparator<Stat>() {
@Override
public int compare(Stat o1, Stat o2) {
return o2.timestamp.compareTo(o1.timestamp);
}
});
return stats;
}
示例15: getBuildsByWorkflow
import hudson.util.RunList; //导入依赖的package包/类
@JavaScriptMethod
public List<Stat> getBuildsByWorkflow(String workflow) {
RunList<B> builds = getBuilds();
if (workflow == null) {
workflow = "null";
}
List<Stat> stats = StatsHelper.getBuildByWorkflow(builds, workflow);
Collections.sort(stats, new Comparator<Stat>() {
@Override
public int compare(Stat o1, Stat o2) {
return o2.timestamp.compareTo(o1.timestamp);
}
});
return stats;
}