Skip to content

Commit

Permalink
Makes Author configurable
Browse files Browse the repository at this point in the history
Due to issues reported by different users I've decided to make the Author field overrideable from the UI. The default will be RequestedForId. More details on how isentities are set: https://docs.microsoft.com/en-us/vsts/build-release/concepts/definitions/build/variables?tabs=batch#identity_values
  • Loading branch information
jessehouwing committed Nov 28, 2017
1 parent ac4d55e commit d020276
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
18 changes: 15 additions & 3 deletions vsts-tfvc-checkin/TfvcCheckin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ param(
[string] $SkipShelveset = $true,
[string] $AutoDetectAdds = $false,
[string] $AutoDetectDeletes = $false,
[string] $BypassGatedCheckin = $false
[string] $BypassGatedCheckin = $false,
[string] $Author,
[string] $AuthorCustom
)

Write-Verbose "Entering script $($MyInvocation.MyCommand.Name)"
Expand Down Expand Up @@ -260,17 +262,27 @@ Try
if (($override -eq $null) -or $OverridePolicy)
{
$checkInParameters = new-object Microsoft.TeamFoundation.VersionControl.Client.WorkspaceCheckInParameters(@($pendingChanges), $Comment)
$checkinParameters.Author = $env:BUILD_QUEUEDBYID

switch ($Author)
{
"RequestedFor" { $AuthorCustom = $env:BUILD_REQUESTEDFOR }
"RequestedForId" { $AuthorCustom = $env:BUILD_REQUESTEDFORID }
"QueuedBy" { $AuthorCustom = $env:BUILD_QUEUEDBY }
"QueuedById" { $AuthorCustom = $env:BUILD_QUEUEDBYID }
"None" { $AuthorCustom = "" }
}
$checkinParameters.Author = $AuthorCustom

if ($CheckinNotes -ne $null)
{
$checkInParameters.CheckinNotes = $CheckinNotes
}

$checkInParameters.PolicyOverride = $override
$checkInParameters.QueueBuildForGatedCheckIn = -not ($BypassGatedCheckin -eq $true)
$checkInParameters.OverrideGatedCheckIn = ($BypassGatedCheckin -eq $true)
$checkInParameters.AllowUnchangedContent = $false
$checkInParameters.NoAutoResolve = $false
#$checkInParameters.CheckinDate = Get-Date

Write-Verbose "Entering Workspace-Checkin"
$provider.VersionControlServer.StripUnsupportedCheckinOptions($checkInParameters)
Expand Down
27 changes: 27 additions & 0 deletions vsts-tfvc-checkin/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,33 @@
"required": true,
"type": "pickList"
},
{
"defaultValue": "RequestedForId",
"groupName": "configurationOptions",
"helpMarkdown": "The Username or Id supplied as Author for the changeset See also: [How are identities set](https://docs.microsoft.com/en-us/vsts/build-release/concepts/definitions/build/variables?tabs=batch#identity_values).<br/><br/>Note: Due to some users reporting issues with previously hardcoded options, this is now configurable.",
"label": "Author",
"name": "Author",
"required": true,
"type": "pickList",
"options": {
"None": "None",
"QueuedByName": "Queued by Username",
"QueuedById": "Queued by Id",
"RequestedFor": "Requested for Username",
"RequestedForId": "Requested for Id",
"Custom": "Custom"
}
},
{
"defaultValue": "",
"groupName": "configurationOptions",
"helpMarkdown": "Specify a custom username or variable expression to use as Author (must evaluate to a known user in VSTS/TFS).",
"label": "Custom Author",
"name": "AuthorCustom",
"required": true,
"type": "string",
"visibleRule": "Author = Custom"
},
{
"defaultValue": "",
"groupName": "configurationOptions",
Expand Down

0 comments on commit d020276

Please sign in to comment.