azure-devopsazure-pipelinesazure-pipelines-release-pipelinerelease-management

Is there a way to only run a deployment job if the downloaded artifact is newer than the one deployed in azure devops?


The current scenario is I want a Release Pipeline that has multiple artifacts (one function and several apis). Each one with a cd trigger except for the one to prod which is manual for right now.

In the pipeline is there a way to prevent a particular job from running if deployed pipeline is the same as the original?

For example, a change is made to one of the apis but the rest remain the same I would want the release to get created and deployed but only run the deployment job linked to that particular artifact.

The reason being is that for a deployment to production it would be nice to have all the artifacts I'm looking to deploy in one place and all I would have to do to deploy to prod would be hitting deploy and if the latest artifact is newer then the one deployed it gets deployed but if it is not that deployment would be skipped.

Right now each artifact is in a separate release pipeline and each gets deployed separately, which means we are keeping a separate document with a list of all the release pipelines that needing to be deployed for a specific set of changes.

Any direction would be appreciated, thanks in advance.


Solution

  • I think you can do that with multi-stages and triggers. You can follow these steps:

    1. Create a release pipeline.
    2. Add all your artifacts.
    3. Create multiple stages. According to your requirement, you may need as many stages as your artifacts.
    4. Set triggers for each stage. Click on the lightning icon to the left of the stage. In "Triggers", select "Afer release". Then enable the "Artifact filters". Choose the artifacts that correspond to this stage as the trigger. Here is an example:

    enter image description here

    Then your release pipeline will be look like this:

    enter image description here

    When an artifact changes, the corresponding stages will be triggered, and no other stages will run.