How can I trigger an update of Azure DevOps pipeline agent major version by script? - azure-devops

I am trying to automate the update of major version on self-hosted agent, by script. I have searched the docs for Azure DevOps REST API to achive this but no luck. I found a solution online that requires you to reinstall the agent on every machine, which is not what I am after. Anyone have a clue? Is there a way to achieve this through the REST API?

Is there a way to achieve this through the REST API?
The answer is yes.
We could use the REST API Agents - Update to update the version of the agent.
PATCH https://dev.azure.com/{organization}/_apis/distributedtask/pools/{poolId}/agents/{agentId}?api-version=5.1
We do not provide the request body for this REST API.
To get the poolId, we could use the REST API Pools - Get Agent Pools:
GET https://dev.azure.com/{organization}/_apis/distributedtask/pools?api-version=5.1
As the result:

Related

Renaming Azure Devops Build and Release pipeline through REST API

trying to rename the pipelines build and release through REST API, I have gone through the official Microsoft documentation but didn't find any API's for this task. Did i miss any or we have such API's where by using build id/build name we can rename the pipeline
have you tried to make the change in the azure release page and look at the request that is being sent in the dev tools network tab? A couple of months ago I was able to learn how to retrieve some information that I was looking for by doing that.
Best regards.
You could use Definitions-Get API to retrieve the requested body by pipeline definition ID.
Copy the response as body and use Definitions-Update to rename the pipeline. Update the pipeline name of this revision.
Check the DevOps UI output.
The above workflow also applies to release pipeline, your need to change the REST API.
Using Releases-Get release to get the latest revision and using Releases - Update Release to rename it

Azure Invoke REST Services with VSTS

As I was working on DevOps Integration with mendix for CI/CD Pipeline creation Using Mendix API (Team Server API, Build API, Deploy API).
With this pipeline I have been using Invoke Rest Services task Invoke HTTP REST API task - Azure Pipelines | Microsoft Docs ,Implement a Simple CICD Pipeline with Mendix APIs | Mendix Documentation these are two documents which I have been referred.
I have created Pipelines for that I have added two invoke REST task.
With the below screenshot, in the GET service I could able to get the revision number and all I need to do is dynamically pass in the POST method to the Revision number attribute which was highlighted.
Kindly provide a solution on the below issues.
Thanks in advance!
Get Method for Team Server API for mendix
Post Method for Build API for mendix

Integrating Service Now with Azure Devops

i am trying to have an integration between service now and azure devops .
If any one can answer below question it be much appreciated.
How to trigger Azure DevOps pipeline automatically on Approving the Change Request in ServiceNow ?
I am approaching with rest API method to call AzureDevops from servicenow plateform.
Does anyone has done something similar and can help me here by listing steps to do so?
You need to create a Service Connection to you ServiceNow instance and then add a Gate in your Release pipeline which creates the Change Request in ServiceNow and then waits for it's status to change.
This provides a good guide - https://learn.microsoft.com/en-us/azure/devops/pipelines/release/approvals/servicenow?view=azure-devops and your gate will end up looking something like this:
You can also use an existing CR but then you'll need a way to supply that to the pipeline on creation of the release.
In the azure devops, we can Install and configure ServiceNow DevOps extension for Azure DevOps to send build and release notifications from your Azure pipeline to ServiceNow DevOps application.
For more details, you can refer this doc: Azure DevOps integration with DevOps

Updating Azure DevOps Environment Resource Tags through the API

I am trying to figure out how to update the associated tags with an Azure DevOps Environment Resource (virtual machine) through the Azure DevOps API.
I have figured out how to get the resources for a specific Environment - https://dev.azure.com/{organization}/{project}/_apis/distributedtask/environments/{environmentId}?api-version=6.0-preview.1
However, if I try to update and then post back the Environment JSON with the updated resource tags, it does not actually update the resources. I think it is only for updating the Environment Name and Description?
I have trying to figure out how to use the following API endpoint (I think this is the one I should be using?) - https://dev.azure.com/{organization}/{project}/_apis/distributedtask/environments/{environmentId}/providers/virtualmachinegroups/{resourceId}/virtualmachines?api-version=6.0-preview.1.
The API endpoint wants a "resourceId" but I am not able to get anything back besides a 404 error when I put in the Environment Resource Id's for my Environment. I am not sure if I am doing something wrong, or this is the wrong end point.
Does anyone have an experience with using the API to update resource tags?
I can reproduce above issue. Currently, You have to manually edit the Environment Virtual machine Resource Tags.
Azure devops Environment Resource Rest API is not fully developed yet. Some features may be broken and unavailable currently.
You can report this issue to Microsoft Development Team. Hope they will fix it in the future sprint.

How to access Azure DevOps deploy comments from REST API

I've been able to successfully access all kinds of details around a release in Azure DevOps by leveraging the .NET client libraries (ex: Microsoft.VisualStudio.Services.Release.Client) that wrap the REST API. However, I can't seem to find what the object/property combination is that I would use to retrieve the comments that can be entered when kicking off a deployment to a specific environment.
To be clear, the comments I'm looking for are entered by hovering over an environment of a release and selecting "Deploy". On the right hand side there is a dialog in which comments can be entered and then another "Deploy" button is selected to kickoff the deployment.
Does anyone have any ideas on how these deployment comments can be read by using the Azure DevOps REST APIs or .NET client libraries?
You can use get release history REST API to get deploy comments:
Get https://vsrm.dev.azure.com/{Organization name}/{Project name}/_apis/Release/releases/{Release Id}/history?api-version=6.1-preview.1
Here is my sample: