tfsaggregator / aggregator-cli

A new version of Aggregator aiming at Azure DevOps (ex Visual Studio Team Services)
https://tfsaggregator.github.io/
Apache License 2.0
74 stars 32 forks source link

Deployed v0.9.9 instance and rule does not update the work items. #124

Closed jprettyman closed 4 years ago

jprettyman commented 4 years ago

Issue: Deployed v0.9.9 instance and rule does not update the work items. Process runs with status OK.

I originally had problems with the v0.9.0 build. Once v0.9.9 was released, I fully purged all deployments for the Aggregator and started fresh. I have a simple rule that sums the values for tasks and writes them to the parent PBI or Bug. It also will write the iteration paths from the PBI or Bug to the child tasks.

When I invoke the rule locally, it runs correctly. It gives the appropriate feedback and indicates the correct work item to update. When I update the work Item, the rule is called and processed giving an OK feedback but no changes are made.

All Log Levels give information except one. It gives this: "Mapping is using Resource Version 5.1-preview.3, which can lead to some issues with e.g. not available relation information on trigger work item."

I tried all resource versions listed in our webhooks configuration: 1.0-Preview.2, 3.1-preview.3, 5.1-preview.3 and [Latest]. Only 3.1 and 5.1 run without errors. This rule ran fine on v0.9.8 string message = "no Changes: ";

This is the rule:

double totValue = 0;
double remainValue = 0;

// Must have a parent
// Must be a Task
// Sum Child tasks for this task parent and set the parent value
if (self.Parent != null && 
    self.WorkItemType == "Task")
{
    var parent = self.Parent;
    var children = parent.Children;

    foreach (var child in children )
    {
        // Only get values from tasks
        if (child.WorkItemType == "Task")
        {
            totValue +=  Convert.ToDouble(child["Microsoft.VSTS.Scheduling.CompletedWork"]);
            remainValue +=  Convert.ToDouble(child["Microsoft.VSTS.Scheduling.RemainingWork"]);
        }
    }
    // only write if there is a summed value
    if (totValue >= 0)
    {
        parent["Microsoft.VSTS.Scheduling.CompletedWork"] = totValue;
    }
    // only write if there is a summed value
    if (remainValue >= 0)
    {
        parent["Microsoft.VSTS.Scheduling.RemainingWork"] = remainValue;
    }

    message = "Calculated Value: " + totValue.ToString() + "-" + remainValue.ToString();
}

// Only process PBI and Bug with Children
if (self.Children != null && 
    (self.WorkItemType == "Product Backlog Item" ||
    self.WorkItemType == "Bug"))
{
    var pChildren = self.Children;

    foreach (var child in pChildren )
    {

        // Only set values for tasks
        if (child.WorkItemType == "Task")
        {
            if (child.AreaPath != self.IterationPath)
            {
                child.AreaPath = self.IterationPath;
            }
        }
    }

    message = "Child Iteration Paths Updated";
}

return message;
RSMJreck commented 4 years ago

What message do you get when using Resource version 1 on the service hook in DevOps? As noted in the message, there are potential issues with using other version and trying to access the relations, which would impact your rule since it is heavily using that with Children and Parent checks/references. I have a very similar rule running on .9.10 without any issues using resource version 1.

jprettyman commented 4 years ago

Well. I tried 1.0 again and it works. I am thinking that when I tried that one I must not have waited long enough for the back-end to catch up. They system is operational.