Skip to content

Make after and before script mututally exclusive to run keyword

What does this MR do and why?

This change adds restrictions to prevent using the run configuration together with before_script and after_script keywords in GitLab CI configuration files. Previously, only using run with script was prohibited, but now this limitation extends to these additional script types as well. The documentation has been updated to reflect this change, and validation logic has been added to the code to enforce these mutual exclusivity rules. The test suite has also been enhanced with parameterized tests to verify that appropriate error messages are displayed when these incompatible combinations are detected.

References

Screenshots or screen recordings

Screenshot_2025-04-28_at_10.13.23_PM

Screenshot_2025-04-28_at_10.13.08_PM

How to set up and validate locally

Use the following errored yaml to check the linter message -

hello_steps:
  after_script: echo # use before_script too
  run:
    - name: steps
      script: echo

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #515684 (closed)

Edited by Rajendra Kadam

Merge request reports

Loading