diff --git a/AzureDevOps.WorkItemClone.ConsoleUI/Commands/WorkItemCloneCommand.cs b/AzureDevOps.WorkItemClone.ConsoleUI/Commands/WorkItemCloneCommand.cs index 9e465fe..3132ae3 100644 --- a/AzureDevOps.WorkItemClone.ConsoleUI/Commands/WorkItemCloneCommand.cs +++ b/AzureDevOps.WorkItemClone.ConsoleUI/Commands/WorkItemCloneCommand.cs @@ -231,7 +231,7 @@ await AnsiConsole.Progress() { { "@projectID", projectItem.id.ToString() }, { "@projectTitle", projectItem.fields["System.Title"].ToString() }, - { "@projectTags", projectItem.fields["System.Tags"].ToString() }, + { "@projectTags", projectItem.fields.ContainsKey("System.Tags") ? projectItem.fields["System.Tags"].ToString() : "" }, { "@RunName", config.RunName } }; var query = await targetApi.CreateProjectQuery(config.targetQueryTitle, config.targetQueryFolder, config.targetQuery, queryParameters); diff --git a/AzureDevOps.WorkItemClone.ConsoleUI/Properties/launchSettings.json b/AzureDevOps.WorkItemClone.ConsoleUI/Properties/launchSettings.json index b1deeaf..ddef29f 100644 --- a/AzureDevOps.WorkItemClone.ConsoleUI/Properties/launchSettings.json +++ b/AzureDevOps.WorkItemClone.ConsoleUI/Properties/launchSettings.json @@ -6,7 +6,7 @@ }, "Clone": { "commandName": "Project", - "commandLineArgs": "clone --cachePath ..\\..\\..\\..\\..\\.cache\\ --configFile ..\\..\\..\\..\\..\\.cache\\configuration-test.json --jsonFile ..\\..\\..\\..\\..\\TestData\\tst_jsonj_export_v20.json --NonInteractive" + "commandLineArgs": "clone --cachePath ..\\..\\..\\..\\..\\.cache\\ --configFile ..\\..\\..\\..\\..\\.cache\\configuration-test.json --jsonFile ..\\..\\..\\..\\..\\TestData\\tst_jsonj_export_v20-lite.json --NonInteractive" }, "empty": { "commandName": "Project" diff --git a/AzureDevOps.WorkItemClone.ConsoleUI/Resources/tst_jsonj_export_v20-lite.json b/AzureDevOps.WorkItemClone.ConsoleUI/Resources/tst_jsonj_export_v20-lite.json new file mode 100644 index 0000000..9e76a24 --- /dev/null +++ b/AzureDevOps.WorkItemClone.ConsoleUI/Resources/tst_jsonj_export_v20-lite.json @@ -0,0 +1,15 @@ +[ + { + "id": 213928, + "fields": { + "System.AreaPath": "Engineering Group\\ECH Group\\ECH TPL 1", + "System.Tags": "Customer Document", + "System.Title": "Technical specification", + "Custom.Product": "CC", + "Microsoft.VSTS.Scheduling.Effort": 12, + "Custom.TRA_Milestone": "E0.1", + "System.Description": "${fromtemplate}", + "Microsoft.VSTS.Common.AcceptanceCriteria": "${fromtemplate}" + } + } +] \ No newline at end of file diff --git a/AzureDevOps.WorkItemClone/DataContracts/WorkItem.cs b/AzureDevOps.WorkItemClone/DataContracts/WorkItem.cs index 431b893..2a31615 100644 --- a/AzureDevOps.WorkItemClone/DataContracts/WorkItem.cs +++ b/AzureDevOps.WorkItemClone/DataContracts/WorkItem.cs @@ -23,25 +23,6 @@ public class WorkItemFull public string url { get; set; } } - public class Fields - { - [JsonProperty("System.Id")] - public int SystemId { get; set; } - [JsonProperty("System.WorkItemType")] - public string SystemWorkItemType { get; set; } - - [JsonProperty("System.Title")] - public string SystemTitle { get; set; } - [JsonProperty("System.Description")] - public string SystemDescription { get; set; } - [JsonProperty("Microsoft.VSTS.Common.AcceptanceCriteria")] - public string MicrosoftVSTSCommonAcceptanceCriteria { get; set; } - [JsonProperty("System.Tags")] - public string SystemTags { get; set; } - [JsonProperty("System.Parent")] - public int SystemParent { get; set; } - } - public class SystemCreatedby { public string displayName { get; set; } diff --git a/README.md b/README.md index e1e6af7..986e70b 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Clones work items from a template project to a target project incorproating a JS "templateOrganization": "orgname", "templateProject": "template Project", "templateParentId": 212315, - "targetQuery": "SELECT [System.Id], [System.WorkItemType], [System.Title], [System.AreaPath],[System.AssignedTo],[System.State] FROM workitems WHERE [System.Parent] = @projectID", + "targetQuery": "SELECT [Custom.Product], [System.Title], [System.Description], [Custom.DeadlineDate], [System.AreaPath], [System.AssignedTo], [System.State], [Custom.Notes], [System.WorkItemType], [Custom.TRA_Milestone] FROM WorkItemLinks WHERE (Source.[System.Id] = @projectID or Source.[System.Parent] = @projectID) and ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward') and (Target.[System.Parent] = @projectID) ORDER BY [Custom.DeadlineDate] mode(Recursive)", "targetQueryTitle": "Project-@RunName - @projectTitle", "targetQueryFolder": "Shared Queries" } @@ -117,6 +117,8 @@ The `id` is the ID of the template item. This will be used to specifiy Descripti The `fields` are the fields that will be used to create the work item. You can use any field ientifyer from Azure DevOps. +Use the `${fromtemplate}` to specify that the value should be taken from the template. This is used here for the Description and Acceptance Criteria, but can be used to pull data from any field. + ```json [ { diff --git a/TestData/tst_jsonj_export_v20-lite.json b/TestData/tst_jsonj_export_v20-lite.json new file mode 100644 index 0000000..9e76a24 --- /dev/null +++ b/TestData/tst_jsonj_export_v20-lite.json @@ -0,0 +1,15 @@ +[ + { + "id": 213928, + "fields": { + "System.AreaPath": "Engineering Group\\ECH Group\\ECH TPL 1", + "System.Tags": "Customer Document", + "System.Title": "Technical specification", + "Custom.Product": "CC", + "Microsoft.VSTS.Scheduling.Effort": 12, + "Custom.TRA_Milestone": "E0.1", + "System.Description": "${fromtemplate}", + "Microsoft.VSTS.Common.AcceptanceCriteria": "${fromtemplate}" + } + } +] \ No newline at end of file