Reputation: 99
I am working on implementing a YAML pipeline to deploy application to the four different environments. Unfortunately I need to perform build every time specific to environment. I have four front end portals and 8 microservices (.NET web API's) related code in a single repo.
For example I have a angular code for one of the front end and I need to execute npm run dev:build, npm run dev:qa ...npm run prod:prod to generate artifacts per environment and then I can deploy on the respective environment.
With environment branching strategy I can deploy easily mean maintaining branches like Dev, QA, UAT and PROD. By creating pull requests I can merge and deploy to the respective environment. But I don't want this complex branching strategy.
So I decided to create a single yaml, and used parameters and conditionals to deploy on respective environment with one click like below Azure DevOps yaml not picking up the parameters
Since I have 4 frontend portals and 8 microservices its difficult to run pipeline with one click manually. So i decided to add triggers for Dev and QA at least and using Release/* branch I want to deploy the code to higher environments.
But when I use triggers and parameters pipeline is not running. When I include parameters I guess Trigger is None.
trigger:
- dev
parameters:
- name: environment
displayName: Environment to choose
type: string
values:
- UAT
variables:
vmImageName: 'windows-2019'
stages:
- stage: DevBuildStage
dependsOn: []
displayName: Dev_Build
jobs:
- job: Build_Job
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: PowerShell@2
displayName: command1
inputs:
targetType: 'inline'
script: |
Write-Host "This is Dev build"
- stage: UATBuildStage
condition: and(succeeded(), eq('${{ parameters.environment }}', 'UAT'))
dependsOn: []
displayName: UAT_Build
jobs:
- job: Build_Job
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: PowerShell@2
displayName: command1
inputs:
targetType: 'inline'
script: |
Write-Host "This is UAT build"
- stage: DeploytoDev
displayName: Deploy to Dev
dependsOn: DevBuildStage
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: 'development'
variables:
- group: dev
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Write-Host "Deploy to Dev"
- stage: DeploytoUAT
displayName: Deploy to UAT
dependsOn: UATBuildStage
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: 'uat'
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
# Write your PowerShell commands here.
Write-Host "Deploy to UAT"
This is how I want to run Dev build and deploy automatically but UAT I can run whenever I need manually using parameters. This way I want to reduce the number of branches.
The simple branching strategy like Dev(Dev environement) --- Release/*(QA, UAT and PROD) --- main (Just to maintain the stable code) Please help me on this issue.
Upvotes: 1
Views: 747
Reputation: 99
Finally I have decided to use environmental branching strategy means a specific branch to deploy to the environment ...Dev(Branch) --- DEV(environment). Also I have used templates to reuse step.
Upvotes: 0