Skip to content

New keyword to run `after_script` for canceled jobs

What does this MR do and why?

Behind a feature flag ci_after_script_on_cancel which will be used for all related issues for the epic.

Here we implement allowing after_script to be a hash in the yaml with when and script as keys.

after_script:
  when: always
  script: echo 'hello world'

The old syntax of a string or array is still valid.

script is required but when is not.

The new keyword defaults to the old behavior which is described by after_script:when:except_cancel.

In a second MR I will implement passing the info to the runner. And also adding it to the json schema in another MR.

How to validate locally

  1. Turn the feature flag on in the rails console (rails c)
Feature.enable(:ci_after_script_on_cancel)
  1. Ensure that a pipeline runs/lints as valid when you submit the commit the syntax:
job1:
  script: echo 'hello'
  after_script: 
    script: echo 'world2'
    when: always

Related to #398774 (closed)

Edited by Allison Browne

Merge request reports

Loading