0
votes

I have a release-pipeline that deploys builds. It's set to run after the build finishes. Builds have a BuildNumber that includes the product version number. I want to only deploy zero builds that have a version number ending with .0

I tried adding a Stage with a Powershell task that checks the version number and fails if it's not a zero build. I also tried to add a gate to the deployment stage that also checks the version number.

Both of these ways of checking result in the release-pipeline failing, and I get an email telling me it's failed.

How can I make the release-pipeline succeed, but do nothing for non-zero builds?

The powershell was:

if ( "$(Release.Artifacts._TheBuild.BuildNumber)" -like ".0 " )
{
    exit 0
}
else
{
    exit 1
}

The gate calls out to an azure function and passes $(Release.Artifacts._TheBuild.BuildNumber) as an argument. The azure function returns json with a status of true or false depending on whether the version number ends with zero. The gate evaluates this immediately, has the minimum retry and timeout of 5 and 6 minutes respectively.

2
Maybe the version number will always be not equal to .0 as per your conditions this will satisfy and fails the release. Also could you please share the powershell scripts, and gate deployment you tried so farJayendran
@Jayendran - I've added the detail to the question. If the version ends with .0 the release continues and succeeds. It's just when it does not end with .0, currently the release shows as failed, but I would like to still be success because nothing has actually failed, I just wanted the release-pipeline to do nothing in this case.Scott Langham

2 Answers

2
votes

This can be done via Custom Condition under the control option (For every task this will be available).

You can achieve this by defining a specific conditions to run the specific task.

In your case, you want to run the task when your version no is 0. So you just define the custom conditions in the control Options to speific the codntion like

and(succeeded(), eq(variables['Release.Artifacts._TheBuild.BuildNumber'], '0'))

enter image description here

So this task will execute only when the condtion satisify else the task will skip it's exectuion.

1
votes

If I understood correctly, you only want to deploy builds that have a version number that ends with .0

You can try adding a release pipeline Continuous Deployment Trigger and add a branch filter that only searches for the version number via a tag.

To do this, first go to the release you want to change, click on the ... ellipsis next to the release name, and click Edit.

This should bring you to the release's pipeline view. Once here, click on the little lighting bolt icon to open the Continuous Deployment Trigger editor:

Azure DevOps - Editing the Continuous Deployment Trigger on a Release Pipeline

This should open the editor on the right hand side. Here you'll see a place to edit Build branch filters. Click on the + Add button to add one.

A new row will popup for you to configure your filter. It's here where I believe you can filter for your version number via build tag.

Azure DevOps - Adding a Build branch filter to a continuous deplyment trigger

Obviously, you will have to edit your build pipeline as well to add this tag so that you can filter for it here in the release.

You would add this tag in the Build tags input.