1
votes

I have a triggers set up in our azure-pipelines.yml like so below:

  1. the scriptsconn represents a connection to the default/self repo that contains the deployment pipeline yaml.

  2. the serviceconn represents a microservice repo we are building and deploying using the template and publish tasks.

We have multiple microservices with similar build pipelines, so this approach is an attempt to lessen the amount of work needed to update these steps.

Right now the issue we're running into is two fold:

  1. no matter what branch we specify in the scriptsconn resources -> repositories section the build triggers for every commit to every branch in the repo.

  2. no matter how we configure the trigger for serviceconn we cannot get the build to trigger for any commit, PR created, or PR merged.

According to the link below this configuration should be pretty straighforward. Can someone point out what mistake we're making?

https://github.com/microsoft/azure-pipelines-yaml/blob/master/design/pipeline-triggers.md#repositories

resources:
  repositories:
    - repository: scriptsconn
      type: bitbucket
      endpoint: BitbucketAzurePipelines
      name: $(scripts.name)
      ref: $(scripts.branch)
      trigger:
        - develop
    - repository: serviceconn
      type: bitbucket
      endpoint: BitbucketAzurePipelines
      name: (service.name)
      ref: $(service.branch)
      trigger:
        - develop
      pr:
        branches:
        - develop


variables:
  - name: service.path
    value: $(Agent.BuildDirectory)/s/$(service.name)
  - name: scripts.path
    value: $(Agent.BuildDirectory)/s/$(scripts.name)
  - name: scripts.output
    value: $(scripts.path)/$(release.folder)/$(release.filename)
  - group: DeploymentScriptVariables.Dev

stages:
- stage: Build
  displayName: Build and push an image
  jobs:  
  - job: Build
    displayName: Build
    pool:
      name: 'Self Hosted 1804'
    steps:   
    - checkout: scriptsconn
    - checkout: serviceconn
1
Does the behavior change if you specify "include" and "exclude" filters for your branches, instead of just listing the branches? docs.microsoft.com/en-us/azure/devops/pipelines/build/…Tony
@Tony no, doesn't change the behavior for either.NealR
@Tony I've added an include and exclude in both statements and neither have changed the respective pipeline's behavior.NealR
@NealR Not get your latest information, is the following answer helpful for you? Or if you have any concern, feel free to share it here.Hugh Lin

1 Answers

0
votes

The document you linked to is actually a design document. So it's possible\likely that not everything on that page is implemented. In the design document I also see this line:

However, triggers are not enabled on repository resource today. So, we will keep the current behavior and in the next version of YAML we will enable the triggers by default.

The current docs on the YAML schema seem to indicate that triggers are not supported on Repository Resources yet.

Just as an FYI you can see the current supported YAML schema at this url.

https://dev.azure.com/{organization}/_apis/distributedtask/yamlschema?api-version=5.1

enter image description here

I am not 100% sure on what you are after template wise. General suggestion, if you are going with the reusable content template workflow, you could trigger from an azure-pipelines.yml file in each of your microservice repos, consuming the reusable steps from your template. Hope that helps!