Search code examples
gitlabgitlab-ci

How to correctly specify stop action for environment in Gitlab


I have the following (simplified) .gitlab-ci.yml file for a project.

It successfully creates an environment that is visible from the UI.

stages:
  - deploy

deploy_test:
  image: #myimage
  stage: deploy
  environment:
    name: test
    url: #myurl
    on_stop: stop_test
  rules:
    - if: '$CI_COMMIT_BRANCH == "mybranch" && $CI_PIPELINE_SOURCE != "merge_request_event"'
  script: #myscript


stop_test:
  stage: deploy
  variables:
    GIT_STRATEGY: none
  script: #myscript     
  when: manual
  environment:
    name: test
    action: stop

However, the stop action doesn't properly get recognized by Gitlab.

Stop action When I press the stop button on the environment, I get greeted with this error message.

I can only "deploy to" the stop_test job.

deploy to

Any ideas on what I did wrong here? "Deploying" to stop_test does execute my script to stop the deployment.

Thanks!


Solution

  • The bug has been fixed with version 16.0 (https://gitlab.com/gitlab-org/gitlab/-/issues/358939#top)