I am trying to invoke the Rest API below for getting list of work items which are mapping to a specific iteration.
https://learn.microsoft.com/en-us/rest/api/azure/devops/work/iterations/get%20iteration%20work%20items?view=azure-devops-rest-5.1
Ultimately I want to invoke this as part of the Approval step in my Release pipeline so that the approver can verify if all work items for a given iteration are in Completed state.
I have two questions:
I don't know how to get the values for {team} and {iterationid}
How do I invoke this API as part of the approval gate. Should I use a Generic service connection? What user name and password do I need to provide?
Any working example here will be really helpful.
To get teams, you can use Teams - Get Teams on Team Project.
Then you can find all team iterations and their ids Iterations - List
You can use gates with azure function. Here is the example: Azure DevOps release gates with Azure Functions, PowerShell and VS Code
Additionally, you may consider to use quality gates with a work item query: Use approvals and gates to control your deployment
Related
A MS teams channel has been configured to notify us after the last stage (prod deployment) in an azure devops pipeline has completed. However, there is a need to include SQL execution statistics like rows affected, duration etc. which I'm capturing in the logs in the release pipeline. Is there way to extract that single task log within a stage in the pipeline and post it to the teams channel?
Currently I'm offering stakeholders the ability to click on the link that takes them to the release within ADO and view the log that way. But I would like to just offer the log on the teams channel and save people time and confusion. I'm including a couple links as reference as to what I have been looking at, the official MS documentation and another is a stack overflow thread with a similar question, but for slack.
If it is done with this api, how would I capture the taskId? I'm not fully understanding how to do this:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}/deployPhases/{releaseDeployPhaseId}/tasks/{taskId}/logs?api-version=5.0-preview.2
Is there a way to list multi-stage automated test run results, on a per stage basis, using Azure DevOps GET Api?
If you call /_apis/pipelines/{pl_def_id}/runs , you will get a list of builds from a defined pipeline.
If you get the latest build from that list, and if that build is multi-stage, the test runs do not seem to be hierarchically beneath the latest build, as you might expect.
To get the test runs, when you call /_apis/test/runs, ( https://learn.microsoft.com/en-us/rest/api/azure/devops/test/runs/list ) it only can give you the list of ALL runs within your org+project. There does not seem to be an id that references the multi-staged "test runs" tasks back to the "parent pipeline" having a "build id".
I looked at timeline queries, but they don't seem to have that info either.
HOW can this be achieved with ADO GET api? Am I overlooking the answer?
There is a parameter buildUri in the run list API as you mentioned the doc:Run List
You can use buildUri to get test runs from a specified build of pipeline.
However, if you want to get multi-stage automated test run results on a per stage, I’m afraid that there’s no supported API to achieve it.
You may submit a feature request at website below:
feature request
I've created the function, which returns JobRequests of agents' jobs through Rest API.
I wonder about some jobs on one agent, which are started at one time but mapped every time to different builds (and when I click on this job in Azure DevOps Web UI - I've got "Build is not found".
I’ve noticed, that all these job requests have the next same parameters:
serviceOwner : 00025394-6065-48ca-87d9-7f5672854ef7
hostId : ffaea179-06ce-45ea-afcd-fde8cd8d156f
scopeId : 6a21ca14-654d-492e-8c3b-83fa3a910dc6
May somebody explain what do these parameters mean (or point to the documentation link, where it is explained).
And how can I get the real Azure DevOps objects using these IDs?
Thank You!
I've been looking at organisation and project settings but I can't see a setting that would prevent users from creating work items in an Azure DevOps project.
I have a number of users who refuse to follow the guidelines we set out for our projects so I'd like to inconvenience them and the wider project team so that they find it better to follow the guidelines than not - at the moment we've got one-word user stories and/or tasks with estimates of 60-70 hours which isn't reflective of the way that we should be planning.
I'd still want them to be able to edit the stories or tasks and moving statuses, but that initial creation should be off-limits for them (for a time at least). Is there a way to do this??
The Azure DevOps Aggregator project allows you to write simple scripts that get triggered when a work item is created or updated. It uses a service hook to trigger when such an event occurs and abstracts most of the API specific stuff away, providing you with an instance of the work item to directly interact with.
You can't block the creation or update from, such a policy, Azure DevOps will inform the aggregator too late in the creation process to do so, but you can revert changes, close the work item etc. There are also a few utility functions to send email.
You need to install the aggregator somewhere, it can be hosted in Azure Functions and we provide a docker container you can spin up anywhere you want. Then link it to Azure DevOps using a PAT token with sufficient permissions and write your first policy.
A few sample rules can be found in the aggregator docs.
store.DeleteWorkItem(self);
should put the work item in the Recycle Bin in Azure DevOps. You can create a code snippet around it that checks the creator of the work item (self.CreatedBy.Id) against a list of known bad identities.
Be mindful that when Azure DevOps creates a new work item the Created and Updated event may fire in rapid succession (this is caused by the mechanism that sets the backlog order on work items), so you may need to find a way to detect what metadata tells you a work item should be deleted. I generally check for a low Revision number (like, < 5) and the last few revisions didn't change any field other than Backlog Priority.
I'd still want them to be able to edit the stories or tasks and moving statuses, but that initial creation should be off-limits for them (for a time at least). Is there a way to do this??
I am afraid there is no such out of setting to do this.
That because the current permission settings for the workitem have not yet been subdivided to apply to the current scenario.
There is a setting about this is that:
Project Settings->Team configuration->Area->Security:
Set this value to Deny, it will prevent users from creating new work items. But it also prevent users from modify the workitem.
For your request, you could add your request for this feature on our UserVoice site (https://developercommunity.visualstudio.com/content/idea/post.html?space=21 ), which is our main forum for product suggestions.
In Azure, you can limit deployments with gates and approvals. Gates are usually some sort of status or health check. Approvals require a certain user or group to manually approve the deployment.
Is it possible to combine the two?
For example, I'd like for a deployment to require an approval but only if it's before 8 am or after 5 pm.
Another example would be to require an approval if the application is not live (liveness would be determined by a REST call).
No there is no way to create "conditional approvals" this way. You can schedule Gates and/or approvals but can't make one dependent on the other. The only thing you can configure is to ignore the gate and still ask for approvals or ask for approvals and then run the gates.
But what you can, using a custom release gate (Azure Function for example), is to do the required check and then use the Azure DevOps REST API to edit the release instance. An azure function with the right permissions could either enable or disable the approvers on the environment or override an approval.
An example of how to do this can be found here:
https://abelsquidhead.com/index.php/2017/12/25/creating-async-custom-automated-release-gates-in-vsts-with-rest-api/
https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/gates.md
https://github.com/Microsoft/azure-pipelines-extensions/tree/master/ServerTaskHelper/DistributedTask.ServerTask.Remote.Common