Azure devops azure devops-如何使用环境变量在任务中创建新变量?

Azure devops azure devops-如何使用环境变量在任务中创建新变量?,azure-devops,yaml,azure-pipelines,pipeline,Azure Devops,Yaml,Azure Pipelines,Pipeline,我可以在任务中获得新的字符串变量 但是如果这个新变量中有环境变量,它将失败 我需要在任务中使用curl来组合API和环境变量以获得新变量 For Simple Example //get string variable in task it work - task: Bash@3 displayName: foovariable inputs: targetType: 'inline' script: | FOO="FOOTEST" echo "#

我可以在任务中获得新的字符串变量 但是如果这个新变量中有环境变量,它将失败 我需要在任务中使用curl来组合API和环境变量以获得新变量

For Simple Example
//get string variable in task it work
- task: Bash@3
  displayName: foovariable
  inputs:
    targetType: 'inline'
    script: |
      FOO="FOOTEST"
      echo "##vso[task.setvariable variable=FOO]$FOO"
- task: Bash@3
  displayName: echofoo
  inputs:
    targetType: 'inline'
    script: |
      echo "$(FOO)"
      //print FOOTEST

//string with variables in new variables then it will fail
variables:
  NAME: Eddy

steps:
- task: Bash@3
  displayName: foovariable
  inputs:
    targetType: 'inline'
    script: |
      Hello="Hi $(NAME)"
      echo "##vso[task.setvariable variable=HELLO]$HELLO"
- task: Bash@3
  displayName: echofoo
  inputs:
    targetType: 'inline'
    script: |
      echo "$(Hello)"
      //I Need it to show "Hi Eddy"
请帮我修改语法
谢谢

您可以尝试使用,不要将名为的环境变量置于双引号中。像这样:

- task: Bash@3
  displayName: foovariable
  inputs:
    targetType: 'inline'
    script: |
      Hello="hi "$NAME
      echo "##vso[task.setvariable variable=HELLO]$Hello"
- task: Bash@3
  displayName: echofoo
  inputs:
    targetType: 'inline'
    script: |
      echo "$(Hello)"
您可以在echofoo步骤中看到,它可以成功打印$(Hello):