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

[WIP] Several Small Fixes #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

[WIP] Several Small Fixes #29

wants to merge 3 commits into from

Conversation

svanoort
Copy link
Member

@svanoort svanoort commented Sep 29, 2016

Work in progress on JENKINS-35656.

Also part of the way towards JENKINS-36322.

Possibly resolves JENKINS-38536 and possibly not.

JENKINS-35656 Tasks:

  • Identify why timestamps are being converted using browser time and not jenkins time (
  • Find a way to get the system time zone/offset from Jenkins and expose it to Stage View
  • EITHER: find a way to incorporate moment-timezone JS library into the FrontEnd build OR use the moment.js offset parsing to handle date formatting
  • Testing, including if property is not set or set to invalid result

JENKINS-36522/JENKINS-38536 Tasks:

  • Don't display NaN values in the UI template
  • Eliminate the way that NaNs are getting added (anything that can't be parsed as a number) and ensure they are not included in any calculations
  • Fix test failure for test_render_stages_in_progress Jasmine test (probably due to a change in the calculation where test expects hardcoded results - if we could, these tests should be properly fixed but I think that may be a tad unrealistic or require converting to an ATH/selenium test).

Pushing this out as a starting point to continue work on, or for someone else to pick up from.

}

// Time zone offset right now in HH:MM format
public String getTimeZoneOffset() {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is used to inject DST-corrected offset for the Jenkins host into the front-end (added in a small script fragment inserted into the placeholder Jelly for stage view).

@@ -181,14 +181,14 @@ function addStageTotals(runGroup) {
var run = runGroup.runs[i];

if (run.stages && (run.status === 'IN_PROGRESS' || run.status === 'PAUSED_PENDING_INPUT')) {
addCompletionEstimates(run, runGroup.avgDurationMillisNoPause, runGroup.runs.length);
addCompletionEstimates(run, runGroup.avgDurationMillisNoPause, endToEndRuns);
Copy link
Member Author

Choose a reason for hiding this comment

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

May avoid factoring incomplete runs into completion estimates. Possible fix for JENKINS-38536

@@ -238,8 +238,8 @@ function addEndTimes(jobRunsData) {
* (i.e. a run, a runGroup or a stage).
*/
function addCompletionEstimates(timedObject, avgDurationMillis, averagedOver) {
if (averagedOver === 0) {
// If no runs have completed yet, then we can't make an estimate, so just mark it at 50%.
if (averagedOver === 0 || !(avgDurationMillis > 0)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Duration > 0 covers NaN and undefined + other weird cases.

@@ -87,6 +91,10 @@ registerHBSHelper('formatDate', function (date, toFormat) {
return date;
}

if (myTimeZoneOffset) { // Do time zone conversion using parseData *sigh.*
//moment.locale(myTimeZone);
Copy link
Member Author

Choose a reason for hiding this comment

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

Here's where we'd inject custom formatting using Jenkins host timeZoneOffset.

Copy link
Member Author

@svanoort svanoort Sep 29, 2016

Choose a reason for hiding this comment

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

Moment.js does have time zone offset options, though they require offset in a particular format and are a little finnicky on parsing.

@@ -21,16 +21,18 @@
<tr class="totals">
<td class="stage-start"><div class="cell-color">
Average stage times:<br />
{{#if avgDurationMillisNoPause}}
{{#ifCond avgDurationMillisNoPause '>' 0 }}
Copy link
Member Author

Choose a reason for hiding this comment

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

Covers NaN, undefined, etc.

@szhem
Copy link

szhem commented Apr 24, 2019

Hi,

It seems that in case of skipped stages (e.g in declarative pipelines) NaNs are still rendered.

pipeline {
  agent 'any'
  stages {
    stage('Stage') {
      when {
        expression { false }
      }
      steps {
        echo 'Hello World!'
      }
    }
  }
}

The pipeline above is rendered as the following
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants