Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Don't pass in the access token, just use the AzureCLI task and do eve…
…rything in the scripts
  • Loading branch information
JimSuplizio authored and azure-sdk committed Jun 11, 2024
commit db6bb1c99cc44fa450c2a1df20c0de7d96976f37
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ steps:
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
$accessToken = az account get-access-token --resource "499b84ac-1321-427f-aa17-267ca6975798" --query "accessToken" --output tsv
$(Build.SourcesDirectory)/eng/common/scripts/Validate-All-Packages.ps1 `
-ArtifactList ('${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json | Select-Object Name) `
-ArtifactPath ${{ parameters.ArtifactPath }} `
Expand All @@ -25,7 +24,6 @@ steps:
-ConfigFileDir '${{ parameters.ConfigFileDir }}' `
-BuildDefinition $(System.CollectionUri)$(System.TeamProject)/_build?definitionId=$(System.DefinitionId) `
-PipelineUrl $(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId) `
-AccessToken $accessToken `
-IsReleaseBuild $$(SetAsReleaseBuild)
workingDirectory: $(Pipeline.Workspace)
displayName: Validate packages and update work items
Expand Down
13 changes: 2 additions & 11 deletions eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@ $ReleaseDevOpsCommonParametersWithProject = $ReleaseDevOpsCommonParameters + @("

function Get-DevOpsRestHeaders()
{
$headers = $null
$headerAccessToken = $null
if (Get-Variable -Name "accessToken" -ValueOnly -ErrorAction "Ignore")
{
$headerAccessToken = $accessToken
}
else
{
# Get a temp access token from the logged in az cli user for azure devops resource
$headerAccessToken = (az account get-access-token --resource "499b84ac-1321-427f-aa17-267ca6975798" --query "accessToken" --output tsv)
}
# Get a temp access token from the logged in az cli user for azure devops resource
$headerAccessToken = (az account get-access-token --resource "499b84ac-1321-427f-aa17-267ca6975798" --query "accessToken" --output tsv)

if ([System.String]::IsNullOrEmpty($headerAccessToken)) {
throw "Unable to create the DevOpsRestHeader due to access token being null or empy. The calling script needs to be pass an the accessToken value OR the calling script needs to be run in an azure authenticated environment."
Expand Down
11 changes: 4 additions & 7 deletions eng/common/scripts/Update-DevOps-Release-WorkItem.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ param(
[string]$packageNewLibrary = "true",
[string]$relatedWorkItemId = $null,
[string]$tag = $null,
[string]$accessToken = $null,
[bool]$inRelease = $true
)
#Requires -Version 6.0
Expand All @@ -29,12 +28,10 @@ if (!(Get-Command az -ErrorAction SilentlyContinue)) {
. (Join-Path $PSScriptRoot SemVer.ps1)
. (Join-Path $PSScriptRoot Helpers DevOps-WorkItem-Helpers.ps1)

if (!$accessToken) {
az account show *> $null
if (!$?) {
Write-Host 'Running az login...'
az login *> $null
}
az account show *> $null
if (!$?) {
Write-Host 'Running az login...'
az login *> $null
}

az extension show -n azure-devops *> $null
Expand Down
4 changes: 1 addition & 3 deletions eng/common/scripts/Validate-All-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Param (
[string]$BuildDefinition,
[string]$PipelineUrl,
[string]$APIViewUri = "https://apiview.dev/AutoReview/GetReviewStatus",
[string]$AccessToken = $null,
[bool] $IsReleaseBuild = $false
)

Expand All @@ -33,8 +32,7 @@ function ProcessPackage($PackageName, $ConfigFileDir)
-APIKey $APIKey `
-BuildDefinition $BuildDefinition `
-PipelineUrl $PipelineUrl `
-ConfigFileDir $ConfigFileDir `
-AccessToken $AccessToken
-ConfigFileDir $ConfigFileDir
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to validate package $PackageName"
exit 1
Expand Down
14 changes: 5 additions & 9 deletions eng/common/scripts/Validate-Package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ param (
[string] $BuildDefinition,
[string] $PipelineUrl,
[string] $APIViewUri,
[string] $AccessToken = $null,
[bool] $IsReleaseBuild = $false
)
Set-StrictMode -Version 3
Expand All @@ -24,12 +23,10 @@ Set-StrictMode -Version 3
. ${PSScriptRoot}\Helpers\ApiView-Helpers.ps1
. ${PSScriptRoot}\Helpers\DevOps-WorkItem-Helpers.ps1

if (!$AccessToken) {
az account show *> $null
if (!$?) {
Write-Host 'Running az login...'
az login *> $null
}
az account show *> $null
if (!$?) {
Write-Host 'Running az login...'
az login *> $null
}

az extension show -n azure-devops *> $null
Expand Down Expand Up @@ -171,8 +168,7 @@ function CreateUpdatePackageWorkItem($pkgInfo)
-packageNewLibrary $pkgInfo.IsNewSDK `
-serviceName "unknown" `
-packageDisplayName "unknown" `
-inRelease $IsReleaseBuild `
-accessToken $AccessToken
-inRelease $IsReleaseBuild

if ($LASTEXITCODE -ne 0)
{
Expand Down