Skip to content

Job history sequence on CI job page is confusing

Summary

Job history sequence on CI job page is confusing

Steps to reproduce

Retrigger a job multiple times

Example Project

What is the current bug behavior?

The sequence of jobs are:

  1. Latest job
  2. Previous jobs in ascending chronological order (i.e. oldest is at the top)

What is the expected correct behavior?

The sequence of jobs should be:

  1. Latest job
  2. Previous jobs in descending chronological order (i.e. oldest is at the bottom)

This means that the entire list is in reverse chronological order, which is logical and easy to understand

Relevant logs and/or screenshots

In this image below, the execution sequence of jobs in the list are:

  1. 4 (i.e. most recent job run)
  2. 1 (i.e. first job run)
  3. 2
  4. 3

image

Output of checks

This bug happens on GitLab.com

Possible fixes

It looks like the /pipelines/<pipeline-id>/stages.json response should be ordered in reverse, as currently it is in ascending job ID order (which is not currently documented in https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/api/jobs.md#list-pipeline-jobs), which is the opposite to the jobs API that returns in descending job ID order (https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/api/jobs.md#list-pipeline-jobs), so it would be good to be consistent:

image


Design proposal

Change the order for the retried section on the jobs detail page to be by name ascending and id descending to better show the order of retrying

Technical proposal

diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index b34d64de101..20c7a80733b 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -48,7 +48,7 @@ class CommitStatus < Ci::ApplicationRecord
   scope :ordered, -> { order(:name) }
   scope :ordered_by_stage, -> { order(stage_idx: :asc) }
   scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) }
-  scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) }
+  scope :retried_ordered, -> { retried.order(name: :asc, id: :desc).includes(project: :namespace) }
   scope :ordered_by_pipeline, -> { order(pipeline_id: :asc) }
   scope :before_stage, -> (index) { where('stage_idx < ?', index) }
   scope :for_stage, -> (index) { where(stage_idx: index) }
Edited by Marius Bobin