diff --git a/eng/common/pipelines/templates/steps/get-pr-owners.yml b/eng/common/pipelines/templates/steps/get-pr-owners.yml index e3739602b229..545143ce09be 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 8452f9fd650b..f28cb3df7899 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 {