Automate everything! - Sync DevOps tasks to ToDo

The low-code landscape is getting really interesting, allowing creation of logic and automation with just a few clicks in a browser.

Originally, I wanted a super simple mobile app for DevOps where I could see my tasks and check them off when done. The apps out there were a bit too clunky for me, so why not use Power Automate as it's part of  my Microsoft 365 license.

Connectors

First off, DevOps and Microsoft ToDo are already connected in Power Automate, so first I created a new automated flow as:

  • From Power Automate, press NEW in the left menu and select Automated Flow in the from blank section
  • Search for the trigger When a work item is updated, Azure DevOps and press Create
  • Now, we add the actions as below

The steps were:

  1. Under When a work item is updated I added a new Initialize Variable as Status, string and no value
  2. Then, add a Switch control for State from the work item and set Status to Completed if Closed, InProgress if Active and NotStarted on default
  3. I then initialize the variable SearchString as string and set it to [[
  4. I then append the ID of the work item (Note: not Id, use ID as it is an integer)
  5. Then I append the closing two ]]
  6. I also initialize a variable named Created to false
  7. I then add a List ToDo Items In Folder and select a folder I created earlier
  8. I then add a Condition Control and check if Body from the todo item contains SearchString
  9. If true then I run Set Variable on Created to true and run Update ToDo item and bind options as below
  10. I then check if the Created was false and if AssignedToEmail was equal to my address, and then use Add new ToDo Item with a similar binding

Now we have sync from DevOps to my ToDo list. I can either use ToDo or the Reminders app in my iPhone.

I also wanted the sync to work the other way, so we create another automation, this time with a trigger on ToDo Item Changed In Specific Folder.

Do a substring by finding position of [[ in the body, then find length, then substring again. This allows us to find the [[4564]] marker containing the ID, see below.

Then, substring from other side to get the marker

Not the most elegant, but works! A Regex function would work so much better of a simpler 'find this string" method, but this will do for now. Finally, I

  1. Use a Condition to check if the TODO task status is Completed
  2. Then, if true, use Get Work Item Details from DevOps using the UID variable I prepared earlier
  3. I use another Condition to ensure the work item State is not Closed. We do not want to cause a loop here.
  4. If false then we should update, so I add the action Update Work Item, use the UID parameter and then set State to Closed.

We now have a very simple tw-way integration between a mobile task list and DevOps. Also, I can quickly see if a new task has been assigned to me. I can now copy the two workflows and set them up for every project that I am a member in. Obviously room for improvement, but with no code, adding a few actions and being able to test run the logic until done, it shows that you can build quite powerful automations with very little effort.