I have diff project in the same organization each team has his own project and i want to automate the creation of userstory from one project to another for exemple
if i have Userstory X in Project 1 assigned to Team1 and i need the intervention of team 2 so we will create a new related userstory in project 1 . i want that new US to be created automatically in the project2 of the second team .
- service hooks to trigger when the userstory is updated and become related to another UserStory
- External Service Endpoints
2
Answers
You can make use of below 2 Approaches to achieve your goal:-
Approach 1:- Azure CLI
Command:-
In this method you get a specific Work Item from source project and then use the output of the Get Work item to create new work item in another project
Output:-
Destination Project:-
Approach 2:- Rest API
You can make use of Get Work Item with Project Name parameter set to the source project name then call Create Work Item API to create new Work Item similar to previous Get Work Item fields.
Approach 2:-
Powershell script to Get Work Item:-
Output:-
Now use Create Work Item to create the Work Item from previous response:-
Sample Powershell code:-
References:-
Work Items – Get Work Item – REST API (Azure DevOps Work Item Tracking) | Microsoft Learn
Work Items – Create – REST API (Azure DevOps Work Item Tracking) | Microsoft Learn
az boards work-item | Microsoft Learn
You can try to use the webhook based triggers to meet your demands with following configurations in project1:
Go to "Project Settings" > "Service hooks" to create a web hook with the "
Work item updated
" event.The request URL is with the format like as below.
For example:
https://dev.azure.com/MyOrg/_apis/public/distributedtask/webhooks/UsAssignedToTeam1?api-version=6.0-preview
Go to "Project Settings" > "Service connections" to create a new "
Incoming Webhook
" service connection. Ensure theWebHook Name
is consistent with that in the request URL.Set up a YAML pipeline like as below.
By this, when a User Story was assigned to the area path of Team1 in project1, it will trigger the web hook, then the web hook will trigger the YAML pipeline. The pipeline will call the RESI API "Work Items – Create" to create a new User Story in project2 and link the User Story in project1 as the "
Related
" type.