D.Goloveyko
D.Goloveyko

Reputation: 41

Azure Pipeline - Trigger working incorrectly

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/*

Upvotes: 0

Views: 376

Answers (1)

DreadedFrost
DreadedFrost

Reputation: 2978

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"

Upvotes: 0

Related Questions