Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[preview] Export users for mapping context #1969

Merged
merged 10 commits into from
Mar 7, 2024

Conversation

MrHinsh
Copy link
Member

@MrHinsh MrHinsh commented Mar 5, 2024

There was a request to have the ability to map users to try and maintain integrity across different systems. We added a TfsUserMappingEnricherthat allows you to map users from Source to Target... this is not free and takes some work. Runnin theExportUsersForMappingConfig` to get the list of users will produce:

[
  {
    "Source": {
      "FriendlyName": "Martin Hinshelwood nkdAgility.com",
      "AccountName": "martin@nkdagility.com"
    },
    "target": {
      "FriendlyName": "Hinshelwood, Martin",
      "AccountName": "martin@othercompany.com"
    }
  },
  {
    "Source": {
      "FriendlyName": "Rollup Bot",
      "AccountName": "Bot@nkdagility.com"
    },
    "target": {
      "FriendlyName": "Service Account 4",
      "AccountName": "randoaccount@somecompany.com"
    }
  },
  {
    "Source": {
      "FriendlyName": "Another non mapped Account",
      "AccountName": "not-mapped@nkdagility.com"
    },
    "target": null
  }
]

##How it works

  1. Run ExportUsersForMappingConfig which will export all of the Users in Soruce Mapped or not to target.
  2. Run WorkItemMigrationConfig which will run a validator by detail to warn you of missing users. If it finds a mapping it will convert the field...

##Notes

  • Applies to all identity fields specified in the list
  • It really sucks that we have to match on Display name! Email is included for internal matching
  • On 'ExportUsersForMappingConfigyou can setOnlyListUsersInWorkItems` to filter the mapping based on the scope of the query. This is greater if you have many users.
  • Both use the TfsUserMappingEnricherOptions setting in CommonEnrichersConfig to know what to do.
{
  "ChangeSetMappingFile": null,
  "Source": {
    "$type": "TfsTeamProjectConfig",
    "Collection": "https://dev.azure.com/nkdagility/",
    "Project": "AzureDevOps-Tools",
    "ReflectedWorkItemIDFieldName": "nkdScrum.ReflectedWorkItemId",
    "AllowCrossProjectLinking": false,
    "AuthenticationMode": "Prompt",
    "PersonalAccessToken": "",
    "PersonalAccessTokenVariableName": "",
    "LanguageMaps": {
      "AreaPath": "Area",
      "IterationPath": "Iteration"
    }
  },
  "Target": {
    "$type": "TfsTeamProjectConfig",
    "Collection": "https://dev.azure.com/nkdagility-preview/",
    "Project": "migrationTest5",
    "ReflectedWorkItemIDFieldName": "nkdScrum.ReflectedWorkItemId",
    "AllowCrossProjectLinking": false,
    "AuthenticationMode": "Prompt",
    "PersonalAccessToken": "",
    "PersonalAccessTokenVariableName": "",
    "LanguageMaps": {
      "AreaPath": "Area",
      "IterationPath": "Iteration"
    }
  },
  "FieldMaps": [],
  "GitRepoMapping": null,
  "LogLevel": "Debug",
  "CommonEnrichersConfig": [
    {
      "$type": "TfsUserMappingEnricherOptions",
      "Enabled": true,
      "UserMappingFile": "C:\\temp\\userExport.json",
      "IdentityFieldsToCheck": [
        "System.AssignedTo",
        "System.ChangedBy",
        "System.CreatedBy",
        "Microsoft.VSTS.Common.ActivatedBy",
        "Microsoft.VSTS.Common.ResolvedBy",
        "Microsoft.VSTS.Common.ClosedBy"
      ]
    }
  ],
  "Processors": [
    {
      "$type": "ExportUsersForMappingConfig",
      "Enabled": true,
      "WIQLQuery": "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') ORDER BY [System.ChangedDate] desc",
      "OnlyListUsersInWorkItems": true
    }
  ],
  "Version": "15.0"
}

Resolves #1976

@github-actions github-actions bot changed the title Export users for mapping context [preview] Export users for mapping context Mar 5, 2024
@MrHinsh MrHinsh self-assigned this Mar 7, 2024
@MrHinsh MrHinsh linked an issue Mar 7, 2024 that may be closed by this pull request
@MrHinsh MrHinsh merged commit bb6032e into preview Mar 7, 2024
6 checks passed
@MrHinsh MrHinsh deleted the preview-ExportUsersForMappingContext branch March 7, 2024 16:46
MrHinsh added a commit that referenced this pull request Mar 15, 2024
## Consecutive Dates

The system will now check that the Revision dates are consecutive. If
there are a bunch of identical dates, it will push each duplicate date
by 1 second to ensure that each one is consecutive.
          
 #1660 #1975

## User Mappings

There was a request to have the ability to map users to try and maintain
integrity across different systems. We added a TfsUserMappingEnricher`
that allows you to map users from Source to Target... this is not free
and takes some work. Runnin the `ExportUsersForMappingConfig` to get the
list of users will produce:

```
[
  {
    "Source": {
      "FriendlyName": "Martin Hinshelwood nkdAgility.com",
      "AccountName": "martin@nkdagility.com"
    },
    "target": {
      "FriendlyName": "Hinshelwood, Martin",
      "AccountName": "martin@othercompany.com"
    }
  },
  {
    "Source": {
      "FriendlyName": "Rollup Bot",
      "AccountName": "Bot@nkdagility.com"
    },
    "target": {
      "FriendlyName": "Service Account 4",
      "AccountName": "randoaccount@somecompany.com"
    }
  },
  {
    "Source": {
      "FriendlyName": "Another non mapped Account",
      "AccountName": "not-mapped@nkdagility.com"
    },
    "target": null
  }
]
```



##How it works

1. Run `ExportUsersForMappingConfig` which will export all of the Users
in Soruce Mapped or not to target.
2. Run `WorkItemMigrationConfig` which will run a validator by detail to
warn you of missing users. If it finds a mapping it will convert the
field...

##Notes
- Applies to all identity fields specified in the list
- It really sucks that we have to match on Display name! Email is
included for internal matching
- On 'ExportUsersForMappingConfig` you can set
`OnlyListUsersInWorkItems` to filter the mapping based on the scope of
the query. This is greater if you have many users.
- Both use the `TfsUserMappingEnricherOptions` setting in
`CommonEnrichersConfig` to know what to do.

```
{
  "ChangeSetMappingFile": null,
  "Source": {
    "$type": "TfsTeamProjectConfig",
    "Collection": "https://dev.azure.com/nkdagility/",
    "Project": "AzureDevOps-Tools",
    "ReflectedWorkItemIDFieldName": "nkdScrum.ReflectedWorkItemId",
    "AllowCrossProjectLinking": false,
    "AuthenticationMode": "Prompt",
    "PersonalAccessToken": "",
    "PersonalAccessTokenVariableName": "",
    "LanguageMaps": {
      "AreaPath": "Area",
      "IterationPath": "Iteration"
    }
  },
  "Target": {
    "$type": "TfsTeamProjectConfig",
    "Collection": "https://dev.azure.com/nkdagility-preview/",
    "Project": "migrationTest5",
    "ReflectedWorkItemIDFieldName": "nkdScrum.ReflectedWorkItemId",
    "AllowCrossProjectLinking": false,
    "AuthenticationMode": "Prompt",
    "PersonalAccessToken": "",
    "PersonalAccessTokenVariableName": "",
    "LanguageMaps": {
      "AreaPath": "Area",
      "IterationPath": "Iteration"
    }
  },
  "FieldMaps": [],
  "GitRepoMapping": null,
  "LogLevel": "Debug",
  "CommonEnrichersConfig": [
    {
      "$type": "TfsUserMappingEnricherOptions",
      "Enabled": true,
      "UserMappingFile": "C:\\temp\\userExport.json",
      "IdentityFieldsToCheck": [
        "System.AssignedTo",
        "System.ChangedBy",
        "System.CreatedBy",
        "Microsoft.VSTS.Common.ActivatedBy",
        "Microsoft.VSTS.Common.ResolvedBy",
        "Microsoft.VSTS.Common.ClosedBy"
      ]
    }
  ],
  "Processors": [
    {
      "$type": "ExportUsersForMappingConfig",
      "Enabled": true,
      "WIQLQuery": "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @teamproject AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') ORDER BY [System.ChangedDate] desc",
      "OnlyListUsersInWorkItems": true
    }
  ],
  "Version": "15.0"
}
```

Resolves #1976
          
Export users for mapping context (#1969) for MrHinsh

---------

Co-authored-by: Nico Orschel <norschel@users.noreply.github.com>
Co-authored-by: Tom Frenzel <40773830+tomfrenzel@users.noreply.github.com>
@aneekers
Copy link

This script on the bottom is giving us an issue since it is in version 15. We tried to do the upgrade to version 16 and it gave us errors that the processor does not exist. We are trying to get the initial export of the users from Version 16 - looks like the corresponding processor in V16 is this one? TfsExportUsersForMappingProcessor

When running this one, we get an error that the TfsUserMappingTool has been disabled. From my understanding, we don't use this tool until we have the mapping ready from the export.

How do we configure it do get the outputted file of users on V16?

@MrHinsh
Copy link
Member Author

MrHinsh commented Sep 25, 2024

The processor is just the entry point, the work is done by the tool.

Add the tool, and enable it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Mapping Users between environments
2 participants