Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
optionsClassName: ExportWorkItemMappingToolOptions
optionsClassFullName: MigrationTools.Tools.ExportWorkItemMappingToolOptions
configurationSamples:
- name: defaults
order: 2
description:
code: There are no defaults! Check the sample for options!
sampleFor: MigrationTools.Tools.ExportWorkItemMappingToolOptions
- name: sample
order: 1
description:
code: There is no sample, but you can check the classic below for a general feel.
sampleFor: MigrationTools.Tools.ExportWorkItemMappingToolOptions
- name: classic
order: 3
description:
code: >-
{
"$type": "ExportWorkItemMappingToolOptions",
"Enabled": false,
"TargetFile": "",
"PreserveExisting": true
}
sampleFor: MigrationTools.Tools.ExportWorkItemMappingToolOptions
description: >-
Tool for exporting mappings of work item IDs from source to target.
Work item migration processor uses this tool to record work item ID mappings.
The mappings will be saved to file defined in options at the end of the migration.
className: ExportWorkItemMappingTool
typeName: Tools
options:
- parameterName: Enabled
type: Boolean
description: If set to `true` then the tool will run. Set to `false` and the processor will not run.
defaultValue: true
isRequired: false
dotNetType: System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
- parameterName: PreserveExisting
type: Boolean
description: >-
Indicates whether existing mappings in the target file should be preserved when saving new mappings.
Default value is `true`.
defaultValue: true
isRequired: false
dotNetType: System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
- parameterName: TargetFile
type: String
description: Path to file, where work item mapping will be saved.
defaultValue: String.Empty
isRequired: false
dotNetType: System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
status: missing XML code comments
processingTarget: missing XML code comments
classFile: src/MigrationTools/Tools/ExportWorkItemMappingTool.cs
optionsClassFile: src/MigrationTools/Tools/ExportWorkItemMappingToolOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ typeName: Tools
options:
- parameterName: ChangeSetMappingFile
type: String
description: missing XML code comments
defaultValue: missing XML code comments
description: Path to changeset mapping file.
defaultValue: null
isRequired: false
dotNetType: System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
- parameterName: Enabled
Expand Down
27 changes: 25 additions & 2 deletions docs/static/schema/configuration.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,28 @@
"CommonTools": {
"type": "object",
"properties": {
"ExportWorkItemMappingTool": {
"title": "ExportWorkItemMappingTool",
"description": "Tool for exporting mappings of work item IDs from source to target.\r\n Work item migration processor uses this tool to record work item ID mappings.\r\n The mappings will be saved to file defined in options at the end of the migration.",
"type": "object",
"properties": {
"Enabled": {
"description": "If set to `true` then the tool will run. Set to `false` and the processor will not run.",
"type": "boolean",
"default": "true"
},
"PreserveExisting": {
"description": "Indicates whether existing mappings in the target file should be preserved when saving new mappings.\r\n Default value is `true`.",
"type": "boolean",
"default": "true"
},
"TargetFile": {
"description": "Path to file, where work item mapping will be saved.",
"type": "string",
"default": "String.Empty"
}
}
},
"FieldMappingTool": {
"title": "FieldMappingTool",
"description": "Tool for applying field mapping transformations to work items during migration, supporting various field mapping strategies like direct mapping, regex transformations, and value lookups.",
Expand Down Expand Up @@ -2229,8 +2251,9 @@
"default": "true"
},
"ChangeSetMappingFile": {
"description": "missing XML code comments",
"type": "string"
"description": "Path to changeset mapping file.",
"type": "string",
"default": "null"
}
}
},
Expand Down
24 changes: 24 additions & 0 deletions docs/static/schema/schema.tools.exportworkitemmappingtool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://devopsmigration.io/schema/schema.tools.exportworkitemmappingtool.json",
"title": "ExportWorkItemMappingTool",
"description": "Tool for exporting mappings of work item IDs from source to target.\r\n Work item migration processor uses this tool to record work item ID mappings.\r\n The mappings will be saved to file defined in options at the end of the migration.",
"type": "object",
"properties": {
"Enabled": {
"description": "If set to `true` then the tool will run. Set to `false` and the processor will not run.",
"type": "boolean",
"default": "true"
},
"PreserveExisting": {
"description": "Indicates whether existing mappings in the target file should be preserved when saving new mappings.\r\n Default value is `true`.",
"type": "boolean",
"default": "true"
},
"TargetFile": {
"description": "Path to file, where work item mapping will be saved.",
"type": "string",
"default": "String.Empty"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"type": "object",
"properties": {
"ChangeSetMappingFile": {
"description": "missing XML code comments",
"type": "string"
"description": "Path to changeset mapping file.",
"type": "string",
"default": "null"
},
"Enabled": {
"description": "If set to `true` then the tool will run. Set to `false` and the processor will not run.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ protected AzureDevOpsPipelineProcessor GetAzureDevOpsPipelineProcessor(AzureDevO
services.AddSingleton<CommonTools>();
services.AddSingleton<IFieldMappingTool, MockFieldMappingTool>();
services.AddSingleton<IWorkItemTypeMappingTool, MockWorkItemTypeMappingTool>();
services.AddSingleton<IExportWorkItemMappingTool, MockExportWorkItemMappingTool>();
services.AddSingleton<IStringManipulatorTool, StringManipulatorTool>();

services.AddSingleton<AzureDevOpsPipelineProcessor>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected TfsTeamSettingsProcessor GetTfsTeamSettingsProcessor(TfsTeamSettingsPr
services.AddSingleton<CommonTools>();
services.AddSingleton<IFieldMappingTool, MockFieldMappingTool>();
services.AddSingleton<IWorkItemTypeMappingTool, MockWorkItemTypeMappingTool>();
services.AddSingleton<IExportWorkItemMappingTool, MockExportWorkItemMappingTool>();
services.AddSingleton<IStringManipulatorTool, StringManipulatorTool>();
services.AddSingleton<IWorkItemQueryBuilderFactory, WorkItemQueryBuilderFactory>();
services.AddSingleton<IWorkItemQueryBuilder, WorkItemQueryBuilder>();
Expand Down Expand Up @@ -107,6 +108,7 @@ protected TfsSharedQueryProcessor GetTfsSharedQueryProcessor(TfsSharedQueryProce
services.AddSingleton<CommonTools>();
services.AddSingleton<IFieldMappingTool, MockFieldMappingTool>();
services.AddSingleton<IWorkItemTypeMappingTool, MockWorkItemTypeMappingTool>();
services.AddSingleton<IExportWorkItemMappingTool, MockExportWorkItemMappingTool>();
services.AddSingleton<IStringManipulatorTool, StringManipulatorTool>();
services.TryAddScoped<IWorkItemQueryBuilderFactory, WorkItemQueryBuilderFactory>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
}
finally
{
CommonTools.ExportWorkItemMapping.SaveMappings();
if (Options.FixHtmlAttachmentLinks)
{
CommonTools.EmbededImages?.ProcessorExecutionEnd(null);
Expand Down Expand Up @@ -439,7 +440,7 @@
newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value = oldWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value;
}
}
catch (FieldDefinitionNotExistException ex)

Check warning on line 443 in src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessor.cs

View workflow job for this annotation

GitHub Actions / Build, Test, Sonar Cloud Analysis, & Package

The variable 'ex' is declared but never used
{
// Eat exception coz the TFS API Sucks
}
Expand Down Expand Up @@ -601,6 +602,7 @@
}
if (targetWorkItem != null)
{
CommonTools.ExportWorkItemMapping.AddMapping(sourceWorkItem.Id, targetWorkItem.Id);
targetWorkItem.ToWorkItem().Close();
}
if (sourceWorkItem != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using MigrationTools.Enrichers;
using MigrationTools.Tools.Infrastructure;
using MigrationTools.Tools.Infrastructure;

namespace MigrationTools.Tools
{
public class TfsChangeSetMappingToolOptions : ToolOptions
{

/// <summary>
/// Path to changeset mapping file.
/// </summary>
/// <default>null</default>
public string ChangeSetMappingFile { get; set; }

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class TfsCommonTools : CommonTools
/// <param name="TfsGitRepositoryTool">Tool for git repository operations</param>
/// <param name="StringManipulatorTool">Tool for string field manipulation</param>
/// <param name="workItemTypeMapping">Tool for work item type mapping</param>
/// <param name="exportWorkItemMapping">Tool for exporting work item mapping.</param>
/// <param name="workItemTypeValidatorTool">Tool for work item type validation.</param>
/// <param name="fieldMappingTool">Tool for field mapping operations</param>
public TfsCommonTools(
Expand All @@ -37,9 +38,10 @@ public TfsCommonTools(
TfsGitRepositoryTool TfsGitRepositoryTool,
IStringManipulatorTool StringManipulatorTool,
IWorkItemTypeMappingTool workItemTypeMapping,
IExportWorkItemMappingTool exportWorkItemMapping,
TfsWorkItemTypeValidatorTool workItemTypeValidatorTool,
IFieldMappingTool fieldMappingTool
) : base(StringManipulatorTool, workItemTypeMapping,fieldMappingTool)
) : base(StringManipulatorTool, workItemTypeMapping, exportWorkItemMapping, fieldMappingTool)
{
UserMapping = userMappingEnricher;
Attachment = attachmentEnricher;
Expand Down
3 changes: 1 addition & 2 deletions src/MigrationTools.Host/Commands/CommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public sealed override async Task<int> ExecuteAsync(CommandContext context, TSet
{
Log.Debug("Disabling Telemetry {CommandName}", this.GetType().Name);
CommandActivity.AddTag("DisableTelemetry", settings.DisableTelemetry);
CommandActivity.Stop();
ActivitySourceProvider.DisableActivitySource();
}
//Enable Debug Trace
Expand Down Expand Up @@ -105,7 +104,7 @@ public sealed override async Task<int> ExecuteAsync(CommandContext context, TSet

internal virtual Task<int> ExecuteInternalAsync(CommandContext context, TSettings settings)
{
return Task.FromResult( 0);
return Task.FromResult(0);
}

public void RunStartupLogic(TSettings settings)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using MigrationTools.Tools.Interfaces;

namespace MigrationTools.Tools.Shadows
{
public class MockExportWorkItemMappingTool : IExportWorkItemMappingTool
{
public void AddMapping(string sourceId, string targetId)
{
}

public void SaveMappings()
{
}
}
}
6 changes: 2 additions & 4 deletions src/MigrationTools/Processors/Infrastructure/Processor.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MigrationTools._EngineV1.Configuration;
using MigrationTools.Endpoints;
using MigrationTools.Endpoints.Infrastructure;
using MigrationTools.Enrichers;
using MigrationTools.Exceptions;
using MigrationTools.Services;
Expand Down Expand Up @@ -139,6 +136,7 @@ public void Execute()
}
finally
{
ProcessorActivity.Stop();
Log.LogInformation("{ProcessorName} completed in {ProcessorDuration} ", Name, ProcessorActivity.Duration.ToString("c"));
}

Expand Down Expand Up @@ -172,4 +170,4 @@ protected static void AddParameter(string name, IDictionary<string, string> stor
if (!store.ContainsKey(name)) store.Add(name, value);
}
}
}
}
1 change: 1 addition & 0 deletions src/MigrationTools/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static void AddMigrationToolServices(this IServiceCollection context, ICo

context.AddSingleton<IStringManipulatorTool, StringManipulatorTool>().AddMigrationToolsOptions<StringManipulatorToolOptions>(configuration);
context.AddSingleton<IWorkItemTypeMappingTool, WorkItemTypeMappingTool>().AddMigrationToolsOptions<WorkItemTypeMappingToolOptions>(configuration);
context.AddSingleton<IExportWorkItemMappingTool, ExportWorkItemMappingTool>().AddMigrationToolsOptions<ExportWorkItemMappingToolOptions, ExportWorkItemMappingToolOptionsValidator>(configuration);

// context.AddSingleton<GitRepoMappingTool>().AddMigrationToolsOptions<GitRepoMappingToolOptions>(configuration);

Expand Down
Loading
Loading