GitLab CI: Support handling value of retry as string
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.
- In an existing project with enabled CI/CD go to CI/CD -> Editor
- 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}
- 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.
-
I have evaluated the MR acceptance checklist for this MR.