1
votes

We are using Azure devops for our CI/CD. Typically, all the CI are written as azure yaml files and the release jobs have to be created on devops portal (using GUI). One of the general principle which we want to follow is to have everything as code.

Questions:

  1. Can Azure release pipelines be created as code (yaml , etc) ?
    • I spent some time on it and it seems it is limited. Please correct me if i am wrong here.
  2. Release pipelines have numerous things like approvals, auto trigger, release trigger, etc . Is it possible with release pipelines in yaml ?
1
1) Yes, using JSON . 2) Yes, using JSON.Cid
I suggest you to export an existing release configuration to see how it looks like (the 3 dots button next to the blue create release one, then click export)Cid
@Cid: that is just exports ( and a huge one). We want to code the release pipelineSunilS
Does this answer your question? Azure DevOps, YAML release pipelines?Shayki Abramczyk
I don't think it provides the features which UI provides .. like approvals ?SunilS

1 Answers

0
votes

Azure deployments can be configured with code. You can add multiple release triggers (pipeline, pull request etc.) Approvals can be configured per environment (https://www.programmingwithwolfgang.com/deployment-approvals-yaml-pipeline/), then reference the environment in your pipeline.

The example below is triggered when its own yaml code changes and when the Build pipeline completes.

trigger:
  branches:
    include: 
    - myBranch
  paths:
    include:
    - '/Deployment/azure-deploy.yml'

resources:
  pipelines:
  - pipeline: BuildPipeline 
    project: myProjectName
    source: 'myBuildPipeline'
    trigger:
      enabled: true
 
jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: $(environment)
    pool:
      vmImage: 'windows-latest'

    strategy:
      runOnce:
        deploy:
          steps:
          - task: AzureRmWebAppDeployment@4
            displayName: Deploy Web App
            inputs:
              ConnectionType: 'AzureRM'
              azureSubscription: $(azureSubscription)
              appType: 'webApp'                
              appSettings: 
                -SETTING-1 "$(mySetting1)"          
              WebAppName: '$(myAppName)'
              package: '$(Pipeline.Workspace)/**/*.zip'


  [1]: https://www.programmingwithwolfgang.com/deployment-approvals-yaml-pipeline/