Reputation: 60391
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.
Upvotes: 0
Views: 2306
Reputation: 10960
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'))
So this task will execute only when the condtion satisify else the task will skip it's exectuion.
Upvotes: 2
Reputation: 1746
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:
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.
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.
Upvotes: 1