0

I have two .yml files in my repo. One for build, one for deployment. The main reason why I would like to keep build separate from the deployment is that I also would like to store variables for environments in my repo, e.i. in variables-dev.yml and variables-prod.yml files. So there is no need to create a new build every time (which includes running tests, docker image build etc.).

The file build.yml:

trigger:
  paths:
    exclude:
      - build.yml
      - deploy.yml

stages:
- stage: build
  jobs:
  ...

And the deploy.yml, which I want to be triggered only on the completion of the build pipeline. That's why I add the first exclusion of all paths, but add one on pipeline resource.

trigger:
  paths:
    exclude:
    - '*'

resources:
  pipelines:
    - pipeline: build
      source: build
      trigger:
        branches:
          include:
          - '*'

stages:
- stage: dev
  variables:
    - template: variables-dev.yml

  jobs:
  - deployment: deploy_dev
    environment: 'dev'
    strategy:
      runOnce:
        deploy:
          steps:
            ...

- stage: prod
  dependsOn: dev
  variables:
    - template: variables-prod.yml

  jobs:
  - deployment: deploy_prod
    environment: 'prod'
    strategy:
      runOnce:
        deploy:
          steps:
            ...

Unfortunately it does not seem to work. The top trigger blocks lower trigger. And if I remove the top trigger than the deploy pipeline is triggered at the same time with the build one.

mibrl12
  • 454
  • 5
  • 21
  • Not get your latest information, is the workaround helpful for you? Or if you have any concern, feel free to share it here. – Hugh Lin Feb 27 '20 at 02:11

2 Answers2

0

you have to start your deploy.yml with trigger: none

trigger: none

resources: 
  pipelines:
  - pipeline: ci-pipeline
    source: my-build-pipeline
    trigger:
      enabled: true
      branches:
        include:
          - master
Alex AIT
  • 17,361
  • 3
  • 36
  • 73
  • Unfortunately does not work. Does this work for you? – mibrl12 Feb 28 '20 at 08:17
  • 1
    Should work... this repo also contains working sample yamls, where ci-xxx.yaml is the build, and cd-xxx.yaml would be your deploy.yaml: https://github.com/Azure/phippyandfriends – Alex AIT Feb 28 '20 at 08:26
  • Hm, alright.. I have a small difference - I do want to trigger the build on all branches. So I put `- "*"` under include :think: – mibrl12 Feb 28 '20 at 08:29
  • Found the documentation for this. Check out `pipeline triggers` here :https://learn.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml#pipeline-triggers – Bevan Feb 28 '20 at 12:51
  • 1
    @AlexAIT my bad!! You were absolutely right. It did not work for me because it was not merged to master and therefore the modification to the trigger was not working. – mibrl12 Mar 05 '20 at 09:50
0

Set your triggers for the second yml to none, then add this setting in the "Triggers" section of the UI. It will stage your builds as you describe

enter image description here

Bevan
  • 1,305
  • 1
  • 11
  • 17