Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setting access token as step output variable #14942

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 13 additions & 1 deletion eng/common/core-templates/steps/get-federated-access-token.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@ parameters:
type: string
- name: outputVariableName
type: string
- name: stepName
type: string
default: 'getFederatedAccessToken'
- name: condition
type: string
default: ''
# Resource to get a token for. Common values include:
# - '499b84ac-1321-427f-aa17-267ca6975798' for Azure DevOps
# - 'https://storage.azure.com/' for storage
# Defaults to Azure DevOps
- name: resource
type: string
default: '499b84ac-1321-427f-aa17-267ca6975798'
- name: isStepOutputVariable
type: boolean
default: false

steps:
- task: AzureCLI@2
displayName: 'Getting federated access token for feeds'
name: ${{ parameters.stepName }}
${{ if ne(parameters.condition, '') }}:
condition: ${{ parameters.condition }}
inputs:
azureSubscription: ${{ parameters.federatedServiceConnection }}
scriptType: 'pscore'
Expand All @@ -25,4 +37,4 @@ steps:
exit 1
}
Write-Host "Setting '${{ parameters.outputVariableName }}' with the access token value"
Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true]$accessToken"
Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true;isOutput=${{ parameters.isStepOutputVariable }}]$accessToken"
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
steps:
- template: /eng/common/core-templates/steps/get-federated-access-token.yml
parameters:
is1ESPipeline: true

${{ each parameter in parameters }}:
${{ parameter.key }}: ${{ parameter.value }}
2 changes: 0 additions & 2 deletions eng/common/templates/steps/get-federated-access-token.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
steps:
- template: /eng/common/core-templates/steps/get-federated-access-token.yml
parameters:
is1ESPipeline: false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this parameter is not defined in core-templates/steps/get-federated-access-token.yml so I think it's not needed


${{ each parameter in parameters }}:
${{ parameter.key }}: ${{ parameter.value }}
Loading