skip to Main Content

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


  1. 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:

    • The pipeline is versioned with your code. It follows the same branching structure. You get validation of your changes through code reviews in pull requests and branch build policies.
    • Every branch you use can modify the pipeline by modifying the corresponding .yml file (or shared YAML templates used by the pipeline)
    • A change to the build process might cause a break or result in an unexpected outcome. Because the change is in version control with the rest of your codebase, you can more easily identify the issue

    See Use Azure Pipelines for more details.

    Login or Signup to reply.
  2. 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 and azure-pipelines-production.yml.

    In each pipeline file, you can specify the branch trigger.

    # azure-pipelines-development.yml
    trigger:
    - development
    
    # azure-pipelines-production.yml
    trigger:
    - master
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search