Skip to content

Change CI errors to split on a newline

Ben King requested to merge benjaminking-ci-error-fix into master

What does this MR do and why?

In the current release of GitLab, .gitlab-ci.yml errors are split on a comma (",") when viewing the status of a pipeline. This can cause problems in the front-end, as some errors contain commas and split the sentence into a new bullet point.

The strings are contained within lib/gitlab/ci/pipeline/seed/build.rb

This MR changes the comma to a newline ("\n")in the show.html.haml file, which now splits the errors correctly, as shown in the examples below.

Screenshots or screen recordings

Example 1 (Maximum Needs)

Before After
image image

|

"#{name}: one job can only need #{max_needs_allowed} others, but you have listed #{@needs_attributes.size}. See needs keyword documentation for more details"

Example 2 (Needs is Missing)

Before After
image image

|

"'#{name}' job needs '#{need[:name]}' job, but '#{need[:name]}' is not in any previous stage" 

How to set up and validate locally

If running this branch, on your local GitLab instance create an empty project. Create a .gitlab-ci.yml file, and use the below contents to generate an error:

stages:
  - init
  
pre structure:
    stage: .pre
    script:
      - echo "hello"
    only:
      - tags 


download base data files:
  stage: init
  script:
    - echo "hello"
  needs:
    - pre structure
  rules:
    - if: '$DATES_TO_PROCESS != "0"'

Navigate to CI > Pipelines, and the pipeline will have failed. Note that the error message is displayed in one-line without being split on the comma.

MR acceptance checklist

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

Edited by Ben King

Merge request reports