AJAY NAIDU
AJAY NAIDU

Reputation: 31

Can we set pre deployment approvals in deploy stage YAML?

Can we set pre deployment conditions in deploy stage YAML ?

I have two stages in my YAML pipeline Azure DevOps (we restrict team to use classic pipelines). I want to know whether we have possibility to set Pre-Deployment Approvals in YAMl for Deploy Stage?

Upvotes: 3

Views: 5156

Answers (3)

adamency
adamency

Reputation: 1538

To clarify the answers which together provide all the information but miss bits of info each:

There is no concept of manual stage approval like in Classic Release pipelines (called pre-deployment approval) for YAML azure pipelines

as is indicated by the official MS doc extract provided by @GeralexGR.

The only workaround officially documented to get the "same" result is to create an environment which you protect with an approval, and then make your stage use this environment

in order to effectively create a manual approval on your stage.

Upvotes: 2

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35544

Can we set pre deployment conditions in deploy stage YAML ?

Yes. You can define the approval in Environment(Pipelines -> Environment).

Here are the steps:

  1. Create Environment.

  2. Navigate to Environment -> Approvals and checks. Then you can add the Approvals in the environment.

enter image description here

  1. Use the Environment in your Deploy Stage.

For example:

- stage: Deploy
  displayName: 'Deploy Web App'
  dependsOn: Build
  condition: succeeded()
  jobs:
  - deployment: DeploymentJob
    environment: envname
    strategy:
      runOnce:
        deploy:
          steps:
           xxxx

For more detailed info, you can refer to this doc: Create and target an environment

Upvotes: 3

GeralexGR
GeralexGR

Reputation: 3592

Do you mean in the release pipeline? You can set your pre-deployment approvals on your release pipelines using gates or an approval from a user.

predeployment-approvals

Configuration of pre-deployment approvals.

enter image description here

If you mean deployment approvals on the build pipeline, you could configure a logic for the build run (specific branch, conditions to evaluate variables and booleans before the run)

As stated in the documentation:

Approvals and other checks are not defined in the yaml file. Users modifying the pipeline yaml file cannot modify the checks performed before start of a stage. Administrators of resources manage checks using the web interface of Azure Pipelines.

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass

Upvotes: -1

Related Questions