本文整理了Java中hudson.model.Run.getDuration
方法的一些代码示例,展示了Run.getDuration
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Run.getDuration
方法的具体详情如下:
包路径:hudson.model.Run
类名称:Run
方法名:getDuration
[英]Gets the millisecond it took to build.
[中]获取构建所需的毫秒数。
代码示例来源:origin: jenkinsci/jenkins
public long getEstimatedDuration() {
List<RunT> builds = getEstimatedDurationCandidates();
if(builds.isEmpty()) return -1;
long totalDuration = 0;
for (RunT b : builds) {
totalDuration += b.getDuration();
}
if(totalDuration==0) return -1;
return Math.round((double)totalDuration / builds.size());
}
代码示例来源:origin: jenkinsci/jenkins
@Override protected void calculate(Run<?,?> build, JSONObject element) {
BallColor iconColor = build.getIconColor();
element.put("iconColorOrdinal", iconColor.ordinal());
element.put("iconColorDescription", iconColor.getDescription());
element.put("buildStatusUrl", build.getBuildStatusUrl());
element.put("number", build.getNumber());
element.put("displayName", build.getDisplayName());
element.put("duration", build.getDuration());
element.put("durationString", build.getDurationString());
if (build instanceof AbstractBuild) {
AbstractBuild<?,?> b = (AbstractBuild) build;
Node n = b.getBuiltOn();
if (n == null) {
String ns = b.getBuiltOnStr();
if (ns != null && !ns.isEmpty()) {
element.put("builtOnStr", ns);
}
} else if (n != Jenkins.getInstance()) {
element.put("builtOn", n.getNodeName());
element.put("builtOnStr", n.getDisplayName());
} else {
element.put("builtOnStr", hudson.model.Messages.Hudson_Computer_DisplayName());
}
}
}
代码示例来源:origin: jenkinsci/jenkins
public TimelineEventList doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) throws IOException {
TimelineEventList result = new TimelineEventList();
for (Run r : builds.byTimestamp(min,max)) {
Event e = new Event();
e.start = new Date(r.getStartTimeInMillis());
e.end = new Date(r.getStartTimeInMillis()+r.getDuration());
// due to SimileAjax.HTML.deEntify (in simile-ajax-bundle.js), "<" are transformed back to "<", but not the "<";
// to protect against XSS
e.title = Util.escape(r.getFullDisplayName()).replace("<", "<");
// what to put in the description?
// e.description = "Longish description of event "+r.getFullDisplayName();
// e.durationEvent = true;
e.link = req.getContextPath()+'/'+r.getUrl();
BallColor c = r.getIconColor();
e.color = String.format("#%06X",c.getBaseColor().darker().getRGB()&0xFFFFFF);
e.classname = "event-"+c.noAnime().toString()+" " + (c.isAnimated()?"animated":"");
result.add(e);
}
return result;
}
代码示例来源:origin: jenkinsci/jenkins
if (r.isBuilding())
continue;
data.add(((double) r.getDuration()) / (1000 * 60), "min",
new ChartLabel(r));
代码示例来源:origin: org.jenkins-ci.plugins/metrics
public long getBuildingDurationMillis() {
return (run == null ? 0L : run.getDuration());
}
代码示例来源:origin: io.fabric8.jenkins.plugins/openshift-sync
private long getDuration(Run run) {
return run.getDuration();
}
代码示例来源:origin: org.jenkins-ci.plugins/python-wrapper
public long superGetDuration() {
return super.getDuration();
}
代码示例来源:origin: DataDog/jenkins-datadog-plugin
/**
* Returns the duration of the run. For pipeline jobs, {@link Run#getDuration()} always returns 0,
* in this case this method will calculate the duration of the run by using the current time as the
* end time.
* @param run - A Run object representing a particular execution of Job.
* @return the duration of the run
*/
private double duration(final Run run) {
if (run.getDuration() != 0) {
return run.getDuration() / DatadogBuildListener.THOUSAND_DOUBLE; // ms to s
} else {
long durationMillis = System.currentTimeMillis() - run.getStartTimeInMillis();
return durationMillis / DatadogBuildListener.THOUSAND_DOUBLE; // ms to s
}
}
代码示例来源:origin: joemiller/jenkins-statsd-plugin
/**
* Returns the duration of the run. For pipeline jobs, {@link Run#getDuration()} always returns 0,
* in this case this method will calculate the duration of the run by using the current time as the
* end time.
* @param run - A Run object representing a particular execution of Job.
* @return - Return the duration of the run
*/
private long calculateDuration(final Run r) {
if (r.getDuration() != 0) {
return r.getDuration();
} else {
long durationMillis = System.currentTimeMillis() - r.getStartTimeInMillis();
return durationMillis;
}
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public long getEstimatedDuration() {
List<RunT> builds = getEstimatedDurationCandidates();
if(builds.isEmpty()) return -1;
long totalDuration = 0;
for (RunT b : builds) {
totalDuration += b.getDuration();
}
if(totalDuration==0) return -1;
return Math.round((double)totalDuration / builds.size());
}
代码示例来源:origin: hudson/hudson-2.x
public final long getEstimatedDuration() {
List<RunT> builds = getLastBuildsOverThreshold(3, Result.UNSTABLE);
if(builds.isEmpty()) return -1;
long totalDuration = 0;
for (RunT b : builds) {
totalDuration += b.getDuration();
}
if(totalDuration==0) return -1;
return Math.round((double)totalDuration / builds.size());
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
public final long getEstimatedDuration() {
List<RunT> builds = getLastBuildsOverThreshold(3, Result.UNSTABLE);
if(builds.isEmpty()) return -1;
long totalDuration = 0;
for (RunT b : builds) {
totalDuration += b.getDuration();
}
if(totalDuration==0) return -1;
return Math.round((double)totalDuration / builds.size());
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
public final long getEstimatedDuration() {
List<RunT> builds = getLastBuildsOverThreshold(3, Result.UNSTABLE);
if (builds.isEmpty()) {
return -1;
}
long totalDuration = 0;
for (RunT b : builds) {
totalDuration += b.getDuration();
}
if (totalDuration == 0) {
return -1;
}
return Math.round((double) totalDuration / builds.size());
}
代码示例来源:origin: groupon/DotCi
private long getBuildDuration(final Run build) {
return build.isBuilding() ? System.currentTimeMillis() - build.getStartTimeInMillis() : build.getDuration();
}
代码示例来源:origin: SonarSource/sonar-scanner-jenkins
/**
* Action that will create the jelly section in the Project page
*/
@CheckForNull
private SonarProjectPageAction createProjectPage(Run<?, ?> run, List<SonarAnalysisAction> actions) {
long endTime = run.getStartTimeInMillis() + run.getDuration();
List<ProjectInformation> projects;
synchronized (run) {
SonarCacheAction cache = getOrCreateCache(run);
projects = cache.get(resolver, endTime, actions);
}
if (projects == null || projects.isEmpty()) {
return null;
}
return new SonarProjectPageAction(projects);
}
代码示例来源:origin: org.jenkins-ci.plugins/python-wrapper
@Override
@Exported
public long getDuration() {
initPython();
if (pexec.isImplemented(23)) {
return pexec.execPythonLong("get_duration");
} else {
return super.getDuration();
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public TimelineEventList doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) throws IOException {
TimelineEventList result = new TimelineEventList();
for (Run r : builds.byTimestamp(min,max)) {
Event e = new Event();
e.start = new Date(r.getStartTimeInMillis());
e.end = new Date(r.getStartTimeInMillis()+r.getDuration());
e.title = r.getFullDisplayName();
// what to put in the description?
// e.description = "Longish description of event "+r.getFullDisplayName();
// e.durationEvent = true;
e.link = req.getContextPath()+'/'+r.getUrl();
BallColor c = r.getIconColor();
e.color = String.format("#%06X",c.getBaseColor().darker().getRGB()&0xFFFFFF);
e.classname = "event-"+c.noAnime().toString()+" " + (c.isAnimated()?"animated":"");
result.add(e);
}
return result;
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
public TimelineEventList doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) throws IOException {
TimelineEventList result = new TimelineEventList();
for (Run r : builds.byTimestamp(min, max)) {
Event e = new Event();
e.start = r.getTime();
e.end = new Date(r.timestamp + r.getDuration());
e.title = r.getFullDisplayName();
// what to put in the description?
// e.description = "Longish description of event "+r.getFullDisplayName();
// e.durationEvent = true;
e.link = req.getContextPath() + '/' + r.getUrl();
BallColor c = r.getIconColor();
e.color = String.format("#%06X", c.getBaseColor().darker().getRGB() & 0xFFFFFF);
e.classname = "event-" + c.noAnime().toString() + " " + (c.isAnimated() ? "animated" : "");
result.add(e);
}
return result;
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
public TimelineEventList doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) throws IOException {
TimelineEventList result = new TimelineEventList();
for (Run r : builds.byTimestamp(min, max)) {
Event e = new Event();
e.start = r.getTime();
e.end = new Date(r.timestamp + r.getDuration());
e.title = r.getFullDisplayName();
// what to put in the description?
// e.description = "Longish description of event "+r.getFullDisplayName();
// e.durationEvent = true;
e.link = req.getContextPath() + '/' + r.getUrl();
BallColor c = r.getIconColor();
e.color = String.format("#%06X", c.getBaseColor().darker().getRGB() & 0xFFFFFF);
e.classname = "event-" + c.noAnime().toString() + " " + (c.isAnimated() ? "animated" : "");
result.add(e);
}
return result;
}
代码示例来源:origin: hudson/hudson-2.x
public TimelineEventList doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) throws IOException {
TimelineEventList result = new TimelineEventList();
for (Run r : builds.byTimestamp(min, max)) {
Event e = new Event();
e.start = r.getTime();
e.end = new Date(r.timestamp + r.getDuration());
e.title = r.getFullDisplayName();
// what to put in the description?
// e.description = "Longish description of event "+r.getFullDisplayName();
// e.durationEvent = true;
e.link = req.getContextPath() + '/' + r.getUrl();
BallColor c = r.getIconColor();
e.color = String.format("#%06X", c.getBaseColor().darker().getRGB() & 0xFFFFFF);
e.classname = "event-" + c.noAnime().toString() + " " + (c.isAnimated() ? "animated" : "");
result.add(e);
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!