Skip to content

GitLab CI: Support handling value of retry as string

Niko requested to merge (removed):retry_as_string into master

What does this MR do and why?

This MR aims at making it possible to use a string for the job retry paramter in GitLab CI.

Given that you want to control the amount of retries based on a variable you currently can not do this. Right now the following pipeline is invalid. The variable for the amount of retries is handled as a string, the error message therefore is This GitLab CI configuration is invalid: retry config has to be either an integer or a hash.

variables:
  RETRIES: 2

first job:
  image: alpine
  script:
    - uname -a
  retry: ${RETRIES}

second job:
  image: alpine
  script:
    - uname -a
  retry: ${RETRIES}

I tried to make the code and tests work to my best knowledge, but since I am not a Ruby dev I believe there is room for improvement. Please feel free to suggest changes.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. In an existing project with enabled CI/CD go to CI/CD -> Editor
  2. Paste the following example code:
    variables:
      RETRIES: 2
    
    first job:
      image: alpine
      script:
        - uname -a
      retry: ${RETRIES}
    
    second job:
      image: alpine
      script:
        - uname -a
      retry: ${RETRIES}
  3. See that the editor complains about it being an invalid configuration because the value of retry has the wrong type.

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 Niko

Merge request reports

Loading