0

I am stuck and confused with Azure Pipelines naming and setup, so crying for help.

I want to run UI automated tests every time the application is deployed.

I have pipeline named 'Application'. It has branch 'release/XXXX' set to default, and also branch 'develop'. Application pipeline is run every time the project should be built for any branch without deploy. But manually I can trigger pipeline to not only build, but also deploy Application to QA environment - it produces pipeline stage 'QaDeploy'.

So I want to start my other pipeline 'UITests' once the 'QaDeploy' stage in 'Application' pipeline exists and is green. The problem is my 'UITests' pipeline gets triggered for every commit to ANY branch.

See below yaml file content. It is content of yaml file in 'release/XXXX' branch, and pipeline us set to use this branch. Please tell me where I am wrong. Thanks in advance.

resources:
  pipelines:
  - pipeline: UITests
    source: Application
    trigger:
      stages:
      - QaDeploy
      branches:
        include:
        - refs/heads/release/*
  • Does this answer your question? [Azure devops pipeline - trigger only on another pipeline, NOT commit](https://stackoverflow.com/questions/59583099/azure-devops-pipeline-trigger-only-on-another-pipeline-not-commit) – Robert Bradley May 11 '23 at 15:19
  • @RobertBradley There are a lot of suggestions in the thread you mentioned. I tried to read it all attentively, I gathered some options there which I need to test. Namely, try to put 'trigger: none'; and set Default branch. I already had Default branch set to 'release/XXXX' - it did not help. I will try to add 'trigger: none' stuff and test it. Is there another option you wanted to explicitly point to me? – D.Goloveyko May 11 '23 at 16:32
  • *So I want to start my other pipeline 'UITests' once the 'QaDeploy' stage in 'Application' pipeline exists and is green. The problem is my 'UITests' pipeline gets triggered for every commit to ANY branch.*. Then you need to adjust the triggers for the `UITest` pipeline. Do you understand what a `resource` means in the context of a pipeline? If not, start by reading up on that. – Daniel Mann May 11 '23 at 17:22

1 Answers1

0

I think your issue is how you are setting a stage as a trigger. The preferred way on this is to have that stage with an if expression or a condition. More on that here or review how a pipeline completion can trigger another pipeline.

# app-ci YAML pipeline
# We are setting up a pipeline resource that references the security-lib-ci
# pipeline and setting up a pipeline completion trigger so that our app-ci
# pipeline runs when a run of the security-lib-ci pipeline completes
resources:
  pipelines:
  - pipeline: securitylib # Name of the pipeline resource.
    source: security-lib-ci # The name of the pipeline referenced by this pipeline resource.
    project: FabrikamProject # Required only if the source pipeline is in another project
    trigger: true # Run app-ci pipeline when any run of security-lib-ci completes

steps:
- bash: echo "app-ci runs after security-lib-ci completes"
DreadedFrost
  • 2,602
  • 1
  • 11
  • 29