Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add job start and duration time to job page #458

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const MultiPipelineGraph = () => {
<table className="jenkins-table sortable">
<thead>
<tr>
<th className="jenkins-table__cell--tight">id</th>
<th data-sort-disable="true">pipeline</th>
<th className="jenkins-table__cell">ID</th>
<th data-sort-disable="true">Pipeline</th>
</tr>
</thead>
<tbody>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export interface RunInfo {
id: string;
displayName: string;
duration: string;
result: string;
startTime: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,26 @@ export const SingleRun: (data: Props) => JSX.Element = ({ run }) => {
}

const handleNodeClick = (nodeName: string, id: number) => {
console.log(nodeName, id);
let redirect = `../${run.id}/pipeline-console?selected-node=${id}`;
if (onJobView) {
redirect = `${run.id}/pipeline-console?selected-node=${id}`;
}
window.location.href = redirect;
};

const jobStatus = `${run.result.toLowerCase()}`;

return (
<tr>
<td>
<a
href={singleRunPage}
className="jenkins-table__link pgw-user-specified-text"
>
{run.displayName}
</a>
<div className="PWGx-PipelineGraph-Summary-container">
<a href={singleRunPage} className={`PWGx-Link ${jobStatus}`}>
<p>{run.displayName}</p>
</a>
<div className="PWGx-Start">
<span>{run.startTime} - {jobStatus === "in_progress" ? "Running..." : run.duration}</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to move this out to its own 'chip' but I wasn't able to make it work in the 10mins or so I had (the display flex column wants each on their own line)

this is probably ok though

image

</div>
</div>
</td>
<td>
<PipelineGraph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,62 @@
margin-right: auto;
}
}

.PWGx-PipelineGraph-Summary-container {
display: flex;
flex-direction: column;
align-items: flex-start;

.PWGx-Link {
border-style: solid;
border-radius: 12px;
border-width: 1px;
display: inline-flex;
align-items: center;
z-index: 3;
position: relative;
background-color: var(--light-grey);
text-decoration: none;

&.aborted {
border-color: var(--text-color-secondary)
}
&.success {
border-color: var(--success-color);
}
&.failure {
border-color: var(--red);
}

p {
font-size: var(--font-size-xs);
margin: 0px 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 200px; /* Adjust the max-width as needed */
}

&:hover p {
color: var(--link-color--hover);
text-decoration: none;
}
}

.PWGx-Duration {
font-size: var(--font-size-xs);
white-space: nowrap;
}

.PWGx-Start {
background: var(--light-grey);
border-radius: 6px;
font-size: 11px;
padding: 7px;
position: relative;
text-align: left;
top: -0.8em;
white-space: nowrap;
display: inline-block;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
package io.jenkins.plugins.pipelinegraphview.multipipelinegraphview;

import hudson.Util;
import hudson.model.Result;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;

public class PipelineRun {

private String id;
private String displayName;
private final String id;
private final String displayName;
private final String duration;
private final String result;
private final String startTime;

public PipelineRun(WorkflowRun run) {
this.id = run.getId();
this.displayName = run.getDisplayName();
this.duration = Util.getTimeSpanString(run.getDuration());

Result buildResult = run.getResult();
this.result = (buildResult != null) ? buildResult.toString() : "IN_PROGRESS";

SimpleDateFormat sdf = new SimpleDateFormat("d MMM, hh:mm", Locale.getDefault());
// TODO support user timezones from UserProperty

Check warning on line 28 in src/main/java/io/jenkins/plugins/pipelinegraphview/multipipelinegraphview/PipelineRun.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: support user timezones from UserProperty
sdf.setTimeZone(TimeZone.getDefault());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users are able to set their own timezone in their user configuration, it would be good to support this, and also the Jenkins timezone property won't be supported by this core Java feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed I would have much rather passed epoch into RunInfo, also respecting a users preference for clock notation(12/24) but that information isn't bubbled up to this plugin yet..

// TODO display full duration on hover but continue shortened for display

Check warning on line 30 in src/main/java/io/jenkins/plugins/pipelinegraphview/multipipelinegraphview/PipelineRun.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: display full duration on hover but continue shortened for display
this.startTime = sdf.format(new Date(run.getStartTimeInMillis()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there was too much info there before, I've shortened it but it would be good to show the full version on hover (ideally client side formatted I just didn't have much time)

}

public String getId() {
Expand All @@ -19,4 +38,16 @@
public String getDisplayName() {
return displayName;
}

public String getDuration() {
return duration;
}

public String getResult() {
return result;
}

public String getStartTime() {
return startTime;

Check warning on line 51 in src/main/java/io/jenkins/plugins/pipelinegraphview/multipipelinegraphview/PipelineRun.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 22-51 are not covered by tests
}
}