How to automatically trigger pipeline step on protected environment after it has been approved

Hello! I have some issues in setting a pipeline using protected environment.

Problem to solve

I have a protected environment where a pipeline is being executed. Specifically, a step (let’s call is approvalStep) needs to be approved by some approvers before starting its execution. I noticed that, after the step is being approved, the pipeline does not keep running by itself. After the step is being approved, a user needs to click to move on with the pipeline execution.

I wonder: are there any ways so that, once the step is being approved (in a protected environment), the pipeline keeps going automatically?

Thanks so much

Can you please provide more detail information about your configuration? (e.g. relevant .gitlab-ci.yml configuration, configuration of Environments from UI, etc)

I have myself a similar situation, and upon approval of deployment on protected environment, my jobs continue to run automatically.

1 Like

Hello @paula.kokic !

Thanks so much for your answer. Sure, I provide more information below.

This is the configuration I have:

  stage: approve-deploy
    name: TrialEnv
    action: start
  allow_failure: false

  when: on_success
    - job: approve-deploy
  stage: apply-deploy
    - ./

  - review-deploy
  - approve-deploy
  - apply-deploy

Let me know if you need more information.

I do think the problem might be in the UI settings where it is mandatory to specify the allowed people to deploy.

Hi @t.92 ,

I will be honest with you - I configured this like a year ago, when there was not so many options, e.g. right now there are Deployment Rules and Approval Rules - and I myself am not sure about the difference.

In my configuration I have only Deployment Rules - I have added persons that should be able to approve the deployment. I don’t have any Approval Rules. Looks like this:

In my .gitlab-ci.yml I have:

  - deploy
  - notify

  stage: deploy
    - echo "Some stuff to deploy to prod"
    name: iCMS IL Production
    deployment_tier: production
  when: manual
  allow_failure: false
   - tags

notify deploy:
  stage: notify
    - echo "Notifying relevant people deployment is done"
  when: on_success
    - tags

And this works as intended - pipeline stops at deploy job, redirecting to Environments page to approve the deployment. When the Approve button is clicked, the job starts automatically, as well as the notify deploy after successful finish of the deploy job.

So, perhaps try removing “allowed to approve” people, just leave deployment rule. And add “when: manual” to your approve-deploy job.

1 Like

Thanks so much @paula.kokic !

It actually worked by also adding in the configuration the line when: manual

Thanks so much!