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

Relations are missing #92

Closed Eckham closed 4 years ago

Eckham commented 4 years ago

Version: 0.9.8

Script:

.language=C#
.import=System
.import=System.Collections
.import=System.Collections.Generic

logger.WriteInfo($"Work Item Id: #{ self.Id }");

logger.WriteInfo($"Relations: {self.RelationLinks.Count()}");

var self2 = store.GetWorkItem(self.Id.Value);

logger.WriteInfo($"Relations: {self2.RelationLinks.Count()}");

if(self.WorkItemType == "Bug" || self.WorkItemType == "Product Backlog Item")
{
    var children = self.Children;

    foreach (var child in children) {
        if (child.WorkItemType == "Task") {

            if(self["Microsoft.VSTS.Common.Priority"] != child["Microsoft.VSTS.Common.Priority"])
            {
                child["Microsoft.VSTS.Common.Priority"] = self["Microsoft.VSTS.Common.Priority"];
                logger.WriteInfo("Priority updated");
            }

            if(self["HABA.Category"] != child["HABA.Category"])
            {
                child["HABA.Category"] = self["HABA.Category"];
                logger.WriteInfo("Category updated");
            }
        }
    }
}

if(self.WorkItemType == "Bug" || self.WorkItemType == "Product Backlog Item" || self.WorkItemType == "Issue")
{
    var children = self.Children;

    foreach (var child in children) {
        if (child.WorkItemType == "Task") {
            if(self.AreaPath != child.AreaPath)
            {
                child.AreaPath = self.AreaPath;
                logger.WriteInfo("Area updated");
            }

            if(self.IterationPath != child.IterationPath)
            {
                if(child.State != "Removed" && child.State != "Done") {
                    child.IterationPath = self.IterationPath;
                    logger.WriteInfo("Iteration updated");
                }
            }

            if(self["Custom.CostCenter"] != child["Custom.CostCenter"])
            {
                if(child.State != "Removed" && child.State != "Done") {
                    child["Custom.CostCenter"] = self["Custom.CostCenter"];
                    logger.WriteInfo("Cost Center updated");
                }
            }
        }
    }
}

var parent = self.Parent;

if (parent != null && (parent.WorkItemType == "Bug" || parent.WorkItemType == "Product Backlog Item" || parent.WorkItemType == "Issue")) 
{

    parent["Microsoft.VSTS.Scheduling.CompletedWork"] = parent.Children.Sum(task => task.GetFieldValue<double>("Microsoft.VSTS.Scheduling.CompletedWork", 0d));
    logger.WriteInfo("CompletedWork cumulated");
}

return "Finished";

Cloud call:

2020-01-03T09:01:04.560 [Information] Executing 'Functions.Project_MSDAX_Rules' (Reason='This function was programmatically called via the host APIs.', Id=b0761fdc-5b66-44ab-83a5-317c9e25f41c)
2020-01-03T09:01:04.568 [Information] Aggregator v0.9.0+local.development executing rule 'Project_MSDAX_Rules'
2020-01-03T09:01:04.927 [Information] Connected to Azure DevOps
2020-01-03T09:01:04.944 [Information] Initial WorkItem 60627 retrieved from https://dev.azure.com/HABAGROUP/
2020-01-03T09:01:06.039 [Information] Work Item Id: #60627
**2020-01-03T09:01:06.040 [Information] Relations: 0
2020-01-03T09:01:06.040 [Information] Relations: 0**
2020-01-03T09:01:06.041 [Information] No changes saved to Azure DevOps.
2020-01-03T09:01:06.041 [Information] Finished
2020-01-03T09:01:06.041 [Information] Returning 'Finished' from 'Project_MSDAX_Rules'
2020-01-03T09:01:06.042 [Information] Executed 'Functions.Project_MSDAX_Rules' (Succeeded, Id=b0761fdc-5b66-44ab-83a5-317c9e25f41c)

Local run works fine:

invoke.rule --dryrun --project "Microsoft Dynamics AX" --event workitem.updated --workItemId 60627 --local --source test\Project_MSDAX_Rules.rule --impersonate

[2020-01-03 10:00:01Z] Aggregator CLI v0.9.0+local.development (build: 0.9.0.0 Release) (c) TFS Aggregator Team
[2020-01-03 10:00:01Z] Connected to subscription 03d4a655-31fb-4dd0-9687-fe74dc238abf
[2020-01-03 10:00:01Z] Connected to dev.azure.com
[2020-01-03 10:00:02Z] Connected to Azure DevOps
[2020-01-03 10:00:02Z] Project Microsoft Dynamics AX data read.
[2020-01-03 10:00:02Z] Initial WorkItem 60627 retrieved from https://dev.azure.com/habagroup
[2020-01-03 10:00:03Z] Work Item Id: #60627
[2020-01-03 10:00:03Z] Relations: 1
[2020-01-03 10:00:03Z] Relations: 1
[2020-01-03 10:00:03Z] Loading workitem 60626
[2020-01-03 10:00:04Z] CompletedWork cumulated
[2020-01-03 10:00:04Z] Dry-run mode: no updates sent to Azure DevOps.
[2020-01-03 10:00:04Z] Found a request to update workitem 60626 in Microsoft Dynamics AX
[2020-01-03 10:00:04Z] Dry-run mode: no updates sent to Azure DevOps.
[2020-01-03 10:00:04Z] Changes saved to Azure DevOps (mode Default): 0 created, 1 updated.
[2020-01-03 10:00:04Z] Rule returned 'Finished'
[2020-01-03 10:00:04Z] Succeeded

Where is my issue?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.