Skip to content

Fix to use self and downstreams builds for duration calculation

Tianwen Chen requested to merge 356759-use-child-pipeline-duration into master

What does this MR do and why?

This MR is to use self and downstreams builds duration instead of self and bridge job duration for upstream pipeline duration.

This issue #387942 (closed) found out that some of the downstream pipelines took a long time (e.g. 6 hours) to kick off running and for example finished in 20mins, which means the duration for a bridge job becomes 6 hours and 20 mins. And user expects to see 20mins.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

  1. Enable the feature flag:
    rails runner 'Feature.enable(:ci_use_downstream_pipeline_duration_for_calculation)'
  2. Create a project 356759-test-duration
  3. Create .gitlab-ci.yml with the following content:
    # .gitlab-ci.yml
    run-child-pipeline:
      trigger:
        include: ci/child-pipeline.yml
        strategy: depend
    
    # ci/child-pipeline.yml
    stages:
      - build
      - test
    
    child-job:
      stage: build
      script:
        - echo "Running child job..."
        - sleep 20
        - echo "Running complete."
    
    run-grand-child-pipeline:
      stage: test
      trigger:
        include: ci/grand-child-pipeline.yml
        strategy: depend
    
    # ci/grand-child-pipeline.yml
    grand-child-job:
      script:
        - echo "Running grand child job..."
        - sleep 15
        - echo "Running complete."
  4. Check if the pipeline takes 35 seconds

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #356759 (closed)

Edited by Tianwen Chen

Merge request reports