GitLab CI/CD environments - One-click rollback with multiple jobs

Hi all, I’m trying to utilize the rollback function and Environments in GitLab, and currently trying to figure out how to properly use it.

I want to achieve a one-click rollback in the web-ui.

My current mock up deployment pipeline is set up as per below.
(the real ci file is quite long)

stages:
  - build
  - pre-deploy
  - deploy

docker_build:
  stage: build
  script:
    - docker build -t $TAG_COMMIT -t $TAG_LATEST .
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - docker push $TAG_COMMIT
  environment:
    name: dev
  tags:
    - builder_01

pre_deploy_server_1:
  stage: pre-deploy
  script:
    - rsync -a src gitlab@fake-host-1:/opt/deployments/$CI_COMMIT_SHORT_SHA
    - ssh gitlab@fake-host-1 "sudo ln -sfn /opt/deployments/$CI_COMMIT_SHORT_SHA /opt/appname"
  environment:
    name: dev
  tags:
    - builder_01

pre_deploy_[server](https://yourexercisebike.com/)_2:
  stage: pre-deploy
  script:
    - rsync -a src gitlab@fake-host-2:/opt/deployments/$CI_COMMIT_SHORT_SHA
    - ssh gitlab@fake-host-2 "sudo ln -sfn /opt/deployments/$CI_COMMIT_SHORT_SHA /opt/appname"
  environment:
    name: dev
  tags:
    - builder_01

deploy:
  stage: deploy
  script:
    - docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
    - docker stack deploy --compose-file docker-compose.yaml stack-name
  environment:
    name: dev
  tags:
    - docker_swarm_manager

The deploy stage and build/pre-deploy needs to be executed in separate runners, and using tags for this.
In my real ci file, the rsync task is executed to 10 severs, with a lot of additional commands not listed here.

I separated each of the rsync jobs as separate jobs to get the granularity in the UI to see exactly which node a deployment failed on.

In a rollback scenario with the current setup, I need to:

  • Go to the Operations → Environments section in GitLab
  • Enter the “dev” environment
  • Click the rollback button for each of the defined jobs as per the above ci file

I’m trying to achieve a one-click rollback solution, and I’m having a hard time understanding how I should structure the config to achieve this. Am I trying to implement something that is not possible?

Any advice or pointers is appreciated!