Forum Discussion
How to pass you variable to env in azure devops?
How to pass you variable to env in azure devops?
````
parameters:
- name: OrganizationName
type: string
- name: AgentPoolName
type: string
- name: ApiVersion
type: string
- name: jobName
type: string
jobs:
- job: deleteOfflineAgents_${{ parameters.jobName }}
displayName: Delete Offline Agents in ${{ parameters.AgentPoolName }} pool
steps:
- script: |
AgentPAT=`aws secretsmanager get-secret-value --secret-id secret --query SecretString --output text | jq -r .secret`
.azurepipelines/scripts/offline-azp-agent-cleaner.sh
displayName: 'Delete Offline Agents'
env:
ORG_NAME: ${{ parameters.OrganizationName }}
AGENT_POOLNAME: ${{ parameters.AgentPoolName }}
API_VERSION: ${{ parameters.ApiVersion }}
AZURE_DEVOPS_AGENT_PAT: $(AgentPAT)
````
when echo AZURE_DEVOPS_AGENT_PAT shows "$(AgentPAT)" not the PAT key "keysample123asd13"
- Loredan6Copper ContributorHello, if you want to assign to the AZURE_DEVOPS_AGENT_PAT the value of the $(AgentPAT) , please make sure that the $(AgentPAT) --> AgentPAT is part of a variable group, in the pipelines section you have "Library" then you need to create a variable group, and in that variable group you need to create an entry with the AgentPAT value and the pair that is the actual - secret. or link it yo an existing keyvault and reference it like that . and you also need to add that variable group into the pipeline. eg. variable group name : PatTokens
variables:
- group: PatTokens
This means you imported the variable group and the variables in that group can no be refferenced as you want and assigned into the pipeline just as your code does above.- Vincent_MajewskiMVCopper ContributorHello Loredan6,
I think that the value of $(AgentPAT), will be different based on the environment. Do you know how we can load this library dynamically (without having to hardcode the environment in the pipeline) ?
more information in the related ticket : https://developercommunity.visualstudio.com/t/stage-dependencies-and-group-variable--/10265756
Thank you for you help