diff --git a/eng/common/pipelines/templates/steps/get-pr-owners.yml b/eng/common/pipelines/templates/steps/get-pr-owners.yml
index e3739602b22..545143ce09b 100644
--- a/eng/common/pipelines/templates/steps/get-pr-owners.yml
+++ b/eng/common/pipelines/templates/steps/get-pr-owners.yml
@@ -6,30 +6,19 @@ steps:
- pwsh: |
git clone https://github.com/Azure/azure-sdk-tools.git $(Build.SourcesDirectory)/tools_repo
cd $(Build.SourcesDirectory)/tools_repo
- git checkout 564ad63ae72d18422533fa1da9d396e7703c1cb5
+ git checkout 35ad98f821913eb0e8872f861ee60589b563c865
displayName: Setup Identity Resolver
- pwsh: |
- $result = dotnet run -v q -- `
+ dotnet run -v q -- `
--aad-app-id-var APP_ID `
--aad-app-secret-var APP_SECRET `
--aad-tenant-var AAD_TENANT `
--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)" `
+ --targetvar "${{ parameters.TargetVariable }}"
displayName: 'Resolving Queuing User'
continueOnError: true
workingDirectory: $(Build.SourcesDirectory)/tools_repo/tools/notification-configuration/identity-resolver
@@ -45,10 +34,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
\ No newline at end of file
+ - 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 }}"
\ No newline at end of file
diff --git a/eng/common/scripts/get-codeowners.ps1 b/eng/common/scripts/get-codeowners.ps1
index 8452f9fd650..f28cb3df789 100644
--- a/eng/common/scripts/get-codeowners.ps1
+++ b/eng/common/scripts/get-codeowners.ps1
@@ -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"
@@ -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 {
diff --git a/tools/notification-configuration/identity-resolver/Program.cs b/tools/notification-configuration/identity-resolver/Program.cs
index 01583430a3a..a89f808041e 100644
--- a/tools/notification-configuration/identity-resolver/Program.cs
+++ b/tools/notification-configuration/identity-resolver/Program.cs
@@ -19,6 +19,7 @@ class Program
/// Kusto DB environment variable name
/// Kusto Table environment variable name
/// The full name of the employee
+ /// The name of DevOps output variable
///
public static async Task Main(
string aadAppIdVar,
@@ -27,7 +28,8 @@ public static async Task Main(
string kustoUrlVar,
string kustoDatabaseVar,
string kustoTableVar,
- string identity
+ string identity,
+ string targetvar
)
{
@@ -35,20 +37,36 @@ string identity
using (var loggerFactory = new LoggerFactory().AddConsole(includeScopes: true))
#pragma warning restore CS0618 // Type or member is obsolete
{
- var githubNameResolver = new GitHubNameResolver(
- Environment.GetEnvironmentVariable(aadAppIdVar),
- Environment.GetEnvironmentVariable(aadAppSecretVar),
- Environment.GetEnvironmentVariable(aadTenantVar),
- Environment.GetEnvironmentVariable(kustoUrlVar),
- Environment.GetEnvironmentVariable(kustoDatabaseVar),
- Environment.GetEnvironmentVariable(kustoTableVar),
- loggerFactory.CreateLogger()
- );
+ try
+ {
+ var githubNameResolver = new GitHubNameResolver(
+ Environment.GetEnvironmentVariable(aadAppIdVar),
+ Environment.GetEnvironmentVariable(aadAppSecretVar),
+ Environment.GetEnvironmentVariable(aadTenantVar),
+ Environment.GetEnvironmentVariable(kustoUrlVar),
+ Environment.GetEnvironmentVariable(kustoDatabaseVar),
+ Environment.GetEnvironmentVariable(kustoTableVar),
+ loggerFactory.CreateLogger()
+ );
- var result = await githubNameResolver.GetMappingInformationFromAADName(identity);
+ var result = await githubNameResolver.GetMappingInformationFromAADName(identity);
- Console.Write(JsonConvert.SerializeObject(result));
+ if (!String.IsNullOrEmpty(targetvar))
+ {
+ Console.WriteLine(String.Format("##vso[task.setvariable variable={0};]{1}", targetvar, result.GithubUserName));
+ }
+ Console.WriteLine(JsonConvert.SerializeObject(result));
+ }
+ catch (Exception e)
+ {
+ if (!String.IsNullOrEmpty(targetvar))
+ {
+ Console.WriteLine(String.Format("##vso[task.setvariable variable={0};]{1}", targetvar, ""));
+ }
+
+ throw e;
+ }
}
}
}
-}
+}
\ No newline at end of file