I am trying to create a development area in my project, I have created a development branch in my repo and I have created pipelines to build that branch to the development function.
I maybe missing something but when I merge branches to the master, its going to merge the pipelines (yaml files) (which are the same with the exception of the trigger), do i just not merge the pipeline or is there a better way to to manage this?
To add further context:
I am trying to create a environments;
one for production and one for development, in the production environment it has a function which has a staging slot, so when the master branch is updated it, uses the master branches pipeline script which restores builds and deploys an artifact to the drop folder (which is the yaml file) which is then used in the release pipeline to deploy to the staging slot (the release pipeline is done in the portal).
the development environment also has a function but not slot at the moment, but also has a pipeline scipt in the development branch of the same repo which restores builds and deploys an artifact to the drop folder (which is the yaml file) which is then used in the release pipeline to deploy to the development function.
They each have there own apim to allow mapping to seperat sub domains domain name.
As far as I am aware the pipelines have to be seperate as I only want the development function to update when the development branch is pushed to and i only want to production staging slot to be pushed to if the master branch is pushed to, meaning the trigger lines have to be different as the trigger is different.
trigger:
- development
pool:
vmImage: ubuntu-latest
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: 'config'
nugetConfigPath: '$(System.DefaultWorkingDirectory)/src/nuget.config'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--output $(Build.BinariesDirectory)/publish_output --configuration Release'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)/publish_output'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
2
Answers
As opposed to the classical build and release pipelines (UI-based), YAML pipelines can be seen as "pipelines-as-code", and are part of your repositories – it makes sense to merge them to master or any other branch.
This means you can manage changes or fixes in the pipelines in the same way you manage changes or fixes in any other file in the repository:
.yml
file (or shared YAML templates used by the pipeline)See Use Azure Pipelines for more details.
You can have two separate pipelines with two yaml files, one for each environment. You can name them differently to avoid confusion, such as
azure-pipelines-development.yml
andazure-pipelines-production.yml
.In each pipeline file, you can specify the branch trigger.
In this way, you can ensure that each environment is updated correctly based on the changes in its respective branch and branch merge will not affect pipelines.