One of the manual processes that we have at SMEx is that when a pull request is accepted, the reviewer needs to go to the linked work item and update the state to "Testing" then create a child task and assign it to the QA staff to test the PBI before it can finally be marked as "Done"

It's a tedious process with many clicks involved, and I think most of the devs here follow the process, sometimes it is still missed. So I began exploring ways to automate the creation of this child testing task.

Thankfully Microsoft has a workflow engine called Flow that plays nicely with VSTS. So here's what you need to do:

Create a new connection to VSTS

  1. Select Settings | Connections
SelectConnections.png
  1. Select New connection
NewConnection.png
  1. Search for "Visual"
  2. Click the "+" next to Visual Studio Team Services
NewVSTSConnection.png
  1. Click Create
CreateVSTSConnection.png

 

  1. Sign into your VSTS account

Create a new Flow

  1. Create a new blank Flow
CreateNewFlow.png
  1. Click on Search hundreds of connectors and triggers
  2. Search for "Visual Studio Team Services"
  3. Select When a work item is updated
SelectWhenAWorkItemIsUpdated.png
  1. Fill in the Account Name, Project Name and Type
WorkItemUpdated.png
  1. Click on + New Step
  2. Select Add a Condition
AddACondition.png
  1. Setup the condition details by checking when the State is equal to Testing
StateEqualsTesting.png
SetCondition.png
  1. In the If Yes box, select Add an action and look for Create a work item
CreateWorkItem.png
  1. Fill in the details to create a new task
CreateWorkItemDetails.png

In the above example, I've created a child task to the PBI with title "<PBI's ID> - Testing. It will have the same area and iteration path as the parent PBI and I've setup the relationship using the Link URL and Link Type.

Note: The dynamic content does provide a URL for the PBI, but it links directly to the revision of the PBI, so that URL in the Link URL won't work. That's why in the Link URL field I've had to hand craft the URL and put in the ID of the PBI. The link types are also as follows:

  • Dependency-forward - Creates a "Successor" relationship
  • Dependency-reverse - Creates a "Predecessor" relationship
  • Hierarchy-forward - Creates a "Child" relationship
  • Hierarchy-reverse - Creates a "Parent" relationship

Save & Test

You flow should now look something like this.

Finished Flow.png

Last but not least, give the flow a name and click "Create Flow"

SaveFlow.png

Now you just need to go and update a PBI's state to "Testing" or whatever state you want and see the flow in action. If you click into the flow, you'll see the history of whenever it ran. If you need to tweak things, you can click on one of the previous runs, and run the flow away (after you've made changes)

I would love to have an event on Pull Request completed, so I can even automate the change of state from Committed to Testing.

 

Comment