Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions eng/common/pipelines/templates/steps/get-pr-owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ steps:
git checkout 564ad63ae72d18422533fa1da9d396e7703c1cb5
displayName: Setup Identity Resolver

- pwsh: |
Write-Host "##vso[task.setvariable variable=${{ parameters.TargetVariable }}]"
displayName: 'Ensure Target Variable Is Populated'

- pwsh: |
$result = dotnet run -v q -- `
--aad-app-id-var APP_ID `
Expand All @@ -17,19 +21,8 @@ steps:
--kusto-url-var KUSTO_URL `
--kusto-database-var KUSTO_DB `
--kusto-table-var KUSTO_TABLE `
--identity "$(Build.QueuedBy)"

$resolvedIdentity = ""
try { $resolvedIdentity = $result[-1] | ConvertFrom-Json } catch {}

if($resolvedIdentity) {
Write-Host $resolvedIdentity

Write-Host "##vso[task.setvariable variable=${{ parameters.TargetVariable }}]$($resolvedIdentity.GithubUserName)"
}
else {
Write-Host "Unable to locate a github user for identity $(Build.QueuedBy)"
}
--identity "$(Build.QueuedBy)" `
--vsoVariable "${{ parameters.TargetVariable }}"
displayName: 'Resolving Queuing User'
continueOnError: true
workingDirectory: $(Build.SourcesDirectory)/tools_repo/tools/notification-configuration/identity-resolver
Expand All @@ -45,10 +38,12 @@ steps:
Remove-Item -Force -Recurse $(Build.SourcesDirectory)/tools_repo
displayName: Clean Up Cloned Tools Repo

- pwsh: |
$originalValue = "$(${{ parameters.TargetVariable }})"
$result = $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1 -TargetDirectory /sdk/${{ parameters.ServiceDirectory }}/ -RootDirectory $(Build.SourcesDirectory)
if ($result) {
Write-Host "##vso[task.setvariable variable=${{ parameters.TargetVariable }}]$originalValue,$result"
}
displayName: Add CodeOwners if Present
- task: PowerShell@2
displayName: Add CodeOwners if Present
inputs:
pwsh: true
filePath: $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1
arguments: >
-TargetDirectory "/sdk/${{ parameters.ServiceDirectory }}/"
-RootDirectory "$(Build.SourcesDirectory)"
-VsoVariable "${{ parameters.TargetVariable }}"
13 changes: 12 additions & 1 deletion eng/common/scripts/get-codeowners.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
param (
$TargetDirectory, # should be in relative form from root of repo. EG: sdk/servicebus
$RootDirectory # ideally $(Build.SourcesDirectory)
$RootDirectory, # ideally $(Build.SourcesDirectory)
$VsoVariable = "" # target devops output variable
)
$target = $TargetDirectory.ToLower().Trim("/")
$codeOwnersLocation = Join-Path $RootDirectory -ChildPath ".github/CODEOWNERS"
Expand Down Expand Up @@ -29,6 +30,16 @@ $results = $ownedFolders[$target]

if ($results) {
Write-Host "Found a folder $results to match $target"

if ($VsoVariable) {
$alreadyPresent = [System.Environment]::GetEnvironmentVariable($VsoVariable)

if ($alreadyPresent) {
$results += ",$alreadyPresent"
}
Write-Host "##vso[task.setvariable variable=$VsoVariable;]$results"
}

return $results
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Program
/// <param name="kustoDatabaseVar">Kusto DB environment variable name</param>
/// <param name="kustoTableVar">Kusto Table environment variable name</param>
/// <param name="identity">The full name of the employee</param>
/// <param name="vsoVariable">The name of DevOps output variable.</param>
/// <returns></returns>
public static async Task Main(
string aadAppIdVar,
Expand All @@ -27,7 +28,8 @@ public static async Task Main(
string kustoUrlVar,
string kustoDatabaseVar,
string kustoTableVar,
string identity
string identity,
string vsoVariable
)
{

Expand All @@ -47,6 +49,11 @@ string identity

var result = await githubNameResolver.GetMappingInformationFromAADName(identity);


if (!String.IsNullOrEmpty(vsoVariable))
{
Console.Write(String.Format("##vso[task.setvariable variable={0};]{1}", vsoVariable, result.GithubUserName));
}
Console.Write(JsonConvert.SerializeObject(result));
}
}
Expand Down