bla9x
bla9x

Reputation: 519

Is there a way to trigger pipeline using Azure Artifacts in YML?

When defining a GUI release I can make it be triggered by an Azure Artifact, is there a way to replicate this for pipelines in YML?

I am building in one AZDO tenant, pushing universal packages to another tenant, where the release definitions will be defined, I'm hoping this can be in YAML. But I don't see an obvious way to do this at the moment?

I see there is a design document that makes mention of packages, but no further details are provided

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

Cheers

Edit- enter image description here

Upvotes: 3

Views: 5440

Answers (3)

Leo Liu
Leo Liu

Reputation: 76660

Is there a way to trigger pipeline using Azure Artifacts in YML?-But I don't see an obvious way to do this at the moment?

Yes, Yes. You are right !

That because the content in this document are speculative, designs, and future features.

If you check the upper level of design document you provided, there is a state:

Azure Pipelines YAML - Design Docs

The design docs within this repo are created at different times during the development of Azure Pipelines, to support collaborative contributions to the design process. Designs documents are for,

  • features considered for implementation but never implemented
  • already implemented features
  • future ideas for features

The design docs in this repo may not represent the current state of an Azure Pipelines feature.

When you check the officially release document YAML schema reference-Resources, it only list:

resources:
  pipelines: [ pipeline ]  
  repositories: [ repository ]
  containers: [ container ]

So, Azure Artifacts source in YAML should be a future feature at this moment. Hope MS can achieve it one day earlier.

Hope this answer clear your question.

Upvotes: 2

Sudarshan_SMD
Sudarshan_SMD

Reputation: 2587

You can use a multi-stage pipeline to achieve this. One stage would include a task that will push your artifacts to the feed. The next stage will contain other jobs that you want to be executed after pushing the Artifacts.

eg:

stages:
#Stage for preparing the Artifact    
   - stage: prepare
      jobs:
       - job: prepare
      pool:
          vmImage: xx        
      steps:
        - task: PublishBuildArtifacts@1
          inputs:
            pathToPublish: xx
            artifactName: xx

# Next stage in your pipeline
- stage: build
  dependsOn: prepare
  jobs:
  steps:
    - task: xx

Note that the second stage build dependsOn the stage prepare.

ps: Multi-Stage pipeline is currently under preview. If you enable it from the preview feature, you will also be able to see a nice visual representation of the stages.

Upvotes: 0

Mohit Verma
Mohit Verma

Reputation: 5296

Build completion triggers are not yet supported in YAML syntax. After you create your YAML build pipeline, you can use the classic editor to specify a build completion trigger.

Reference:

https://learn.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml#build-completion-triggers

Though i would suggest you to use below mechanism to trigger the release:

  • Resource triggers

    Resources trigger will be helpful in below scenario:

    • I would like to trigger my pipeline when an artifact is published by ‘Helm-CI’ pipeline that ran on releases/* branch.
    • I would like to trigger my pipeline when an artifact is published and tested as part of Helm-CI pipeline and tagged as 'Production'.
    • I would like to trigger my pipeline when ‘TFS-Update’ pipeline has completed ‘Ring2’ stage so that I can run some diagnostics.

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

  • Webhook triggers At the end of the CI piepleing , you can add a task to hit webhook url which can trigger your CD is one way.

Hope it helps.

Upvotes: 0

Related Questions