How to get a warning in Release pipeline? - azure-devops

I have a Release Pipeline which do some stuffs. One of my tasks display warning but at task status i read 'succedeed' and also on release status level.
Whenever a warning is reported, i would like that task also be on warning state.
How can i achieve that ?
i also try some setting here
Thanks for your help

Related

Azure Devops deployment failure: The 'Performing deployment' operation conflicts with the pending 'Performing deployment' operation

I am trying to create a devops pipeline to deploy an azure function.
Each time I try I get the error:
BadRequest: The 'Performing deployment' operation conflicts with the
pending 'Performing deployment' operation started at 2022-08-16T13:01:47.6881726Z.
Please retry operation later.
I have waited 2 hours and still get this error.
In the resource group, i cannot see any pending deployments, only failed deployments.
Also, get-AzDeployment cmdlet returns no data so i cant find any deployments that may be blocking.
Any ideas how to resolve this?
The message usually indicates that there is another pending deployment operation that is ongoing and it would prevent the new deployment. However, you don't see any results from running the get-AzDeployment cmdlet. Additionally, you can run the Get-AzDeploymentOperation cmdlet as it lists all the operations that were part of a deployment to help you identify and give more information about the exact operations that failed for a particular deployment.
https://learn.microsoft.com/en-us/powershell/module/az.resources/get-azdeploymentoperation?view=azps-8.3.0
I found the issue was due to exporting the arm template from the portal.
For some reason the portal included a bunch of "deployments" in the template. These deployments which had already run were clashing when I ran the template.
I've no idea why it includes old deployments in the template but deleting them resolved that particular issue.

Is there a way to configure retries for Azure DevOps pipeline tasks or jobs?

Currently I have a OneBranch DevOps pipeline that fails every now and then while restoring packages. Usually it fails because of some transient error like a socket exception or timeout. Re-trying the job usually fixes the issue.
Is there a way to configure a job or task to retry?
Azure Devops now supports the retryCountOnTaskFailure setting on a task to do just this.
See this page for further information:
https://learn.microsoft.com/en-us/azure/devops/release-notes/2021/pipelines/sprint-195-update
Update:
Automatic retries for a task was added and when you read this it should be available for usage.
It can be used as follow:
- task: <name of task>
retryCountOnTaskFailure: <max number of retries>
...
Here are a few things to note when using retries:
The failing task is retried immediately.
There is no assumption about the idempotency of the task. If the task has side-effects (for instance, if it created an external resource partially), then it may fail the second time it is run.
There is no information about the retry count made available to the task.
A warning is added to the task logs indicating that it has failed before it is retried.
All of the attempts to retry a task are shown in the UI as part of the same task node.
Original answer:
There is no way of doing that with native tasks. However, if you can script then you can put such logic inside.
You could do this for instance in this way:
n=0
until [ "$n" -ge 5 ]
do
command && break # substitute your command here
n=$((n+1))
sleep 15
done
However there is no native way of doing this for regular tasks.
Automatically retry a task in on roadmap so it could change in near future.

Conditionally run an Azure DevOps job only if a specific prior job has failed

In Azure DevOps, I'm trying to make it so that a release job (not a YAML pipeline job) only runs if a specific prior job has failed. One of the pre-defined conditions for running a job is "Only when a previous job has failed", but this is not appropriate because it includes all prior jobs, rather than just the last job (or better yet, a job of the users choosing).
Please note that this question focuses on tasks within a job and is not the answer that I am looking for.
According to the documentation for conditions under "How can I trigger a job if a previous job succeeded with issues?", I can access the result of a previous job -
eq(dependencies.A.result,'SucceededWithIssues')
Looking at the logs for a previous release, the AGENT_JOBNAME for the job that I wish to check is Post Deployment Tests, so that would mean that my condition should look like this. However, Azure DevOps wont even let me save my release -
not(eq(dependencies.Post Deployment Tests.result, 'succeeded'))
Job condition for job "Swap Slots Back on Post Deployment Test Failure" in stage "Dev" is invalid: Unexpected symbol: 'Deployment'.
I've tried to wrap the job name in quotes, but I get similar errors -
not(eq(dependencies.'Post Deployment Tests'.result, 'succeeded'))
not(eq(dependencies."Post Deployment Tests".result, 'succeeded'))
I've also tried to reference my job using underscores, which does allow me to save the release but then results in an error at run time -
not(eq(dependencies.Post_Deployment_Tests.result, 'succeeded'))
Unrecognized value: 'dependencies'.
How can I achieve me goal of conditionally running a job only if a specific prior job has failed?
How can I achieve me goal of conditionally running a job only if a
specific prior job has failed?
1.You should know that Yaml pipeline and Classic pipeline use difference technologies.
See feature ability, they have different features. Also, they have quite different behavior for Conditions though they(Yaml,Classic Build,Classic Release) all support job conditions.
The eq(dependencies.'Post Deployment Tests'.result, 'succeeded') you're trying is not supported in Classic(UI) Release pipeline. It's for Yaml:
It's expected behavior to get error like Unrecognized value: 'dependencies' cause the job dependency is not supported in Release pipeline. See this old ticket.

Azure DevOps: How's the deployment group job status decided?

I have a deployment group job with setting in below pic as 33%. How's the status of job determined to be "failed" or partially succeeded"? The description of the setting only specifies "It is also used to determine the success and failure conditions during deployment" which is not really clarifying.
In first attempt, status is failed even though only 4 machines didn't succeed
After couple of attempts, status is "partially succeeded" even though 23 failed
I think you should have been know that this does not has any relevant with the number of the failed deployment.
In fact, this only relevant with one option: Continue on error
When you enable this option in the task, even one step failed, it will still continue the deploying. At last, it will display partially succeeded.
Instead, if you did not check this Continue on error option, even it only has one failed step, the status will still display failed.
To verify this, you can check your task configuration which exists in Control Options.
Also, you can check this thread: VSTS Release - Phase with partially succeeded.
Deployment group phase will be “partially succeeded” if deployment is
attempted to all the targets, event the deployment is failed in any of
the target.
I found the answer from the link in Merlin's answer below : "Deployment group phase will be “partially succeeded” if deployment is attempted to all the targets, event the deployment is failed in any of the target."
Couldn't locate this piece of info anywhere in the official docs.

Timeout for a whole pipeline w/manual steps in Azure DevOps

I have created a release pipeline in Azure DevOps, with several stages, deployments to each environment. On some of the environments (Test and Production), I have manual approval tasks (not set in YAML, but on the environment). If the approval task is not performed within a set time, I want the whole pipeline to cancel.
I have set a timeoutInMinutes on the stage itself, however, the timeout never starts, as the stage is waiting for the approval before it can start at all.
I haven't found a way to set a timeout on the approval/review activity, nor have I found a way to have a different stage/job independent of the others sit and wait for a timeout and cancel the job with a logging command ##vso[task.complete result=Canceled;]DONE
See the screenshot. The pipeline just sits and waits forever. Any ideas?
Timeout for a whole pipeline w/manual steps in Azure DevOps
Yes, you are right. I could reproduced this issue on my side.
As we know, the Timeout is used:
To avoid taking up resources when your job is hung or waiting too
long, it's a good idea to set a limit on how long your job is allowed
to run.
When we set the checks on the stage. Our job is in the pending state not Running, At this time, the timeout we set has not yet started working. It only starts timing after our job starts running. So, we need a timeout for the checks, just like the timeout for Pre-deployment approvals:
I could not find any solution/workaround after spending a long time, but I found this is a highly prioritized feature requirement that has been tracked by the Azure Devops teams after confirming with Azure devops teams.
Now, I could see the status of this feature timeout for the checks request is In Progress at sprint 158,
I believe this feature will meet us soon, please pay attention to the release notes of Azure devops. Thank you for helping us build a better Azure DevOps.
Hope this helps.