diff --git a/src/WorkItemMigrator/JiraExport/RevisionUtils/FieldMapperUtils.cs b/src/WorkItemMigrator/JiraExport/RevisionUtils/FieldMapperUtils.cs index fc02040f..d1d87001 100644 --- a/src/WorkItemMigrator/JiraExport/RevisionUtils/FieldMapperUtils.cs +++ b/src/WorkItemMigrator/JiraExport/RevisionUtils/FieldMapperUtils.cs @@ -174,6 +174,24 @@ public static object MapSprint(string iterationPathsString) if (string.IsNullOrWhiteSpace(iterationPathsString)) return null; + // For certain configurations of Jira, the entire Sprint object is returned by the + // fields Rest API instead of the Sprint name + if (iterationPathsString.StartsWith("com.atlassian.greenhopper.service.sprint.Sprint@")) + { + Regex regex = new Regex(@",name=([^,]+),"); + Match match = regex.Match(iterationPathsString); + if (match.Success) + { + iterationPathsString = match.Groups[1].Value; + } + else + { + Logger.Log(LogLevel.Error, "Missing 'name' property for Sprint object. " + + $"Skipping mapping this sprint. The full object was: '{iterationPathsString}'." + ); + } + } + var iterationPaths = iterationPathsString.Split(',').AsEnumerable(); iterationPaths = iterationPaths.Select(ip => ip.Trim()); var iterationPath = iterationPaths.Last(); diff --git a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/FieldMapperUtilsTests.cs b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/FieldMapperUtilsTests.cs index 9b9bb7e4..6072fe2f 100644 --- a/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/FieldMapperUtilsTests.cs +++ b/src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/FieldMapperUtilsTests.cs @@ -215,6 +215,18 @@ public void When_calling_map_sprint_with_invalid_azdo_chars_Then_expected_output Assert.AreEqual(expected, output); } + [Test] + public void When_calling_map_sprint_with_full_sprint_object_as_str_Then_expected_output_is_returned() + { + string sprintPath = "com.atlassian.greenhopper.service.sprint.Sprint@7c6e1967[id=442906,rapidViewId" + + "=187524,state=ACTIVE,name=LMS 2024_05,startDate=2024-10-14T00:00:00.000Z,endDate=2024-11-01T" + + "23:00:00.000Z,completeDate=,activatedDate=2024-10-13T18:14:54.334Z,sequence=449386,goa" + + "l=,synced=false,autoStartStop=false,incompleteIssuesDestinationId=]"; + string expectedOutput = "LMS 2024_05"; + object output = FieldMapperUtils.MapSprint(sprintPath); + Assert.AreEqual(expectedOutput, output); + } + [Test] public void When_calling_map_value_with_valid_args_Then_expected_output_is_returned() {