Skip to content

Commit

Permalink
Updated to use the templates work item type!
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHinsh committed Jul 3, 2024
1 parent a958e99 commit 5544a76
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ await AnsiConsole.Progress()
AnsiConsole.WriteLine($"Processing {buildItems.Count()} items");
task6.Description = $"[bold]Stage 6[/]: Create Work Items (0/{buildItems.Count()})";
task6.StartTask();
await foreach ((WorkItemToBuild witb, string status, int skipped, int failed, int created) result in CreateWorkItemsToBuild(buildItems, projectItem, targetApi, config.targetWorkItemType))
await foreach ((WorkItemToBuild witb, string status, int skipped, int failed, int created) result in CreateWorkItemsToBuild(buildItems, projectItem, targetApi))
{
//AnsiConsole.WriteLine($"Stage 6: Processing {witb.guid} for output of {witb.relations.Count - 1} relations");
task6.Increment(1);
Expand Down Expand Up @@ -266,6 +266,7 @@ private async IAsyncEnumerable<WorkItemToBuild> generateWorkItemsToBuildList(Lis
newItem.guid = Guid.NewGuid();
newItem.hasComplexRelation = false;
newItem.templateId = item.id;
newItem.workItemType = templateWorkItem.fields.SystemWorkItemType;
newItem.fields = new Dictionary<string, string>()
{
{ "System.Title", item.fields.title },
Expand Down Expand Up @@ -309,7 +310,7 @@ private async IAsyncEnumerable<WorkItemToBuild> generateWorkItemsToBuildRelation
}
}

private async IAsyncEnumerable<(WorkItemToBuild, string status, int skipped, int failed, int created)> CreateWorkItemsToBuild(List<WorkItemToBuild> workItemsToBuild, WorkItemFull projectItem, AzureDevOpsApi targetApi, string workItemTypeToCreate)
private async IAsyncEnumerable<(WorkItemToBuild, string status, int skipped, int failed, int created)> CreateWorkItemsToBuild(List<WorkItemToBuild> workItemsToBuild, WorkItemFull projectItem, AzureDevOpsApi targetApi)
{
int skipped = 0;
int failed = 0;
Expand All @@ -323,7 +324,7 @@ private async IAsyncEnumerable<WorkItemToBuild> generateWorkItemsToBuildRelation
} else
{
WorkItemAdd itemToAdd = CreateWorkItemAddOperation(item, workItemsToBuild, projectItem);
WorkItemFull newWorkItem = await targetApi.CreateWorkItem(itemToAdd, workItemTypeToCreate);
WorkItemFull newWorkItem = await targetApi.CreateWorkItem(itemToAdd, item.workItemType);
if (newWorkItem != null)
{
created++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ internal class WorkItemCloneCommandSettings : BaseCommandSettings
[Description("The project name for the target location")]
[CommandOption("--targetProject")]
public string? targetProject { get; set; }
[Description("The Name of the work item type to use when creating")]
[CommandOption("--targetWorkItemType|--wit")]
[DefaultValue("Deliverable")]
public string? targetWorkItemType { get; set; }
[Description("The ID of the work item in the target environment that will be the parent of all created work items.")]
[CommandOption("-p|--parentId|--targetParentId")]
public int? targetParentId { get; set; }
Expand All @@ -52,6 +48,9 @@ internal class WorkItemCloneCommandSettings : BaseCommandSettings
[Description("The project name for the template location")]
[CommandOption("--templateProject")]
public string? templateProject { get; set; }
[Description("The ID of the work item in the template environment under which we will read all the sub items.")]
[CommandOption("--templateParentId")]
public int? templateParentId { get; set; }
//------------------------------------------------
}
}
1 change: 1 addition & 0 deletions AzureDevOps.WorkItemClone/DataContracts/WorkItemToBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public class WorkItemToBuild
public bool hasComplexRelation { get; set; }
public string targetUrl { get; set; }

Check warning on line 12 in AzureDevOps.WorkItemClone/DataContracts/WorkItemToBuild.cs

View workflow job for this annotation

GitHub Actions / Build & Test

Non-nullable property 'targetUrl' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public int targetId { get; set; }
public string workItemType { get; set; }

Check warning on line 14 in AzureDevOps.WorkItemClone/DataContracts/WorkItemToBuild.cs

View workflow job for this annotation

GitHub Actions / Build & Test

Non-nullable property 'workItemType' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}
}

0 comments on commit 5544a76

Please sign in to comment.