TransWikia.com

Azure DevOps Pipelines running on incorrect branches

DevOps Asked by nulltron on December 2, 2021

I’m attempting to build different branches with different YAML configuration files in each branch. However, when I commit to a branch that should only trigger 1 pipeline it triggers both.

Project Pipelines

Development YAML:

    trigger:
    - master_Development
    
    pool:
      vmImage: 'windows-latest'
    
    variables:
      solution: '**/*.sln'
      buildPlatform: 'Any CPU'
      buildConfiguration: 'Release'
      buildPackageDirectory: 'packages'
      nugetConfig: 'SW.Api.Net/nuget.config'
    
    steps:
    
    - task: NuGetToolInstaller@0
      displayName: 'Use NuGet 4.4.1'
      inputs:
        versionSpec: 4.4.1
    
    - task: NuGetCommand@2
      displayName: 'NuGet restore'
      inputs:
        restoreSolution: $(solution)
        feedsToUse: config
        nugetConfigPath: $(nugetConfig)
        externalFeedCredentials: TelerikFeed
        restoreDirectory: $(buildPackageDirectory)
    
    - task: VSBuild@1
      displayName: 'Build solution'
      inputs:
        solution: $(solution)
        msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)\"'
        platform: $(buildPlatform)
        configuration: $(buildConfiguration)
    
    - task: VSTest@2
      displayName: 'Test Assemblies'
      inputs:
        testFiltercriteria: 'TestCategory=Unit Test'
        platform: $(buildPlatform)
        configuration: $(buildConfiguration)
    
    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact: drop'
      inputs:
        PathToPublish: $(build.artifactStagingDirectory)
        ArtifactName: 'drop'
      condition: succeededOrFailed()


Production YAML:

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  buildPackageDirectory: 'packages'
  nugetConfig: 'SW.Api.Net/nuget.config'

steps:

- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: $(solution)
    feedsToUse: config
    nugetConfigPath: $(nugetConfig)
    externalFeedCredentials: TelerikFeed
    restoreDirectory: $(buildPackageDirectory)

- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    solution: $(solution)
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)\"'
    platform: $(buildPlatform)
    configuration: $(buildConfiguration)

- task: VSTest@2
  displayName: 'Test Assemblies'
  inputs:
    testFiltercriteria: 'TestCategory=Unit Test'
    platform: $(buildPlatform)
    configuration: $(buildConfiguration)

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathToPublish: $(build.artifactStagingDirectory)
    ArtifactName: 'drop'
  condition: succeededOrFailed()

Why would the pipelines not be separately triggering they target different branches?

One Answer

I have solved this issue, it had to do with the path to the pipeline.

I created a directory called pipelines/dev and pipelines/prod in the root of my repo. And I pointed either build pipeline to the respective yaml config file. Now it will only build on the commit of the specific branches.

Answered by nulltron on December 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP