It's possible to run the next stage in the pipeline if previous one got failed or even still running

Summary

Violation of the pipeline execution is detected. Now we can able to e.g. deploy to production if previous stage with testing on stage has been failed or still being executed. The problem is that cancel/retry button is visible for the downstream stage

Steps to reproduce

  1. Add the following lines into .gitlab-ci.yml
stages:
  - stage1
  - stage2

testing:on:stage:
  stage: stage1
  script: 
    - 'exit 1'
    
deploy:to:production:
  stage: stage2
  script:
    - 'echo stage2 that should be never executed'
  1. Run the pipeline
  2. Observe the stage2 while stage is still in progress (see the first screenshot attached)
  3. Click cancel button for the stage2
  4. Click retry button for stage2
  5. Observe the magic happening for stage2 (even if stage1 fails before/after the result is the same)

Example Project

https://gitlab.com/denys.pavlenko1/denys_test

What is the current bug behavior?

Cancel/ retry buttons appear for not started downstream stage in a pipeline thus it possible to e.g. deploy to production suddenly (or on purpose) if previous stage got failed

What is the expected correct behavior?

Cancel/ retry button should not appear for not started downstream stage in a pipeline thus it won't be possible to e.g. deploy to production suddenly (or on purpose) if previous stage got failed and blocks the pipeline

Relevant logs and/or screenshots

Screenshots are attached

Screenshot_2019-11-29_at_14.44.10

Screenshot_2019-11-29_at_14.44.17

Screenshot_2019-11-29_at_14.44.34

Screenshot_2019-11-29_at_14.45.59

Output of checks

This bug happens on GitLab.com as well as on our company's instance

Results of GitLab environment info

The issue can be reproduced on the following versions:

  • GitLab Enterprise Edition 12.5.0-pre 9e0448ab
  • GitLab Enterprise Edition 11.11.8-ee

Possible workaround

It may be possible to achieve expected behavior using a combination of when or if (where applicable) paired with needs like this example.

stages:
  - stage1
  - stage2

testing:on:stage:
  stage: stage1
  script: 
    - 'exit 1'
    
deploy:to:production:
  stage: stage2
  script:
    - 'echo stage2 that should be never executed'
  needs: ["testing:on:stage"]

Possible fixes

none

Edited by James Heimbuck