如何在间接更改这些变量的同一构建中为后续步骤刷新环境变量?
节的一部分,该测试YAML文件再现所描述的行为。
jobs:
- job: welldone
pool:
name: noodle
steps:
- script: |
echo select TestStand 2016
start /wait "" "C:\Program Files (x86)\National Instruments\Shared\TestStand Version Selector\TSVerSelect.exe" /version 16.0 /installing /noprompt
displayName: 'select TestStand version 16'
- script: |
echo Check TestStand version
echo %TestStand%
call RefreshEnv.cmd
echo %TestStand%
displayName: 'print TestStand version'
- script: |
call checkTSversion.bat
call RefreshEnv.cmd
call checkTSversion.bat
displayName: 'call bat file to print TestStand version'第一个脚本调用TestStand Version Selector,其中包括更改环境变量。
第二个脚本打印以"teststand“开头的环境变量,然后调用refreshenv.cmd并再次打印变量。第一次打印旧变量,第二次更新。我想,这与cmd的预期行为是一致的。
第三个脚本也做同样的事情,但是现在echo %TestStand%在一个单独的批处理文件中。它的行为和第二个脚本完全一样。
我可以在第一个脚本中做什么,以确保连续的脚本将读取更新的环境变量?
发布于 2020-02-06 16:31:47
我不能完全确定我是否理解您的示例管道,但在我看来,您似乎希望在作业步骤中设置变量和/或更改变量值,然后在稍后的作业步骤中使用新值。对,是这样?如果是这样的话,你正在寻找类似这样的东西:
steps:
# Create a variable
# Note that this does _not_ update the environment of the current script.
- bash: |
echo "##vso[task.setvariable variable=sauce]crushed tomatoes"
# An environment variable called `SAUCE` has been added to all downstream steps
- bash: |
echo "my environment variable is $SAUCE"
- pwsh: |
Write-Host "my environment variable is $env:SAUCE"https://stackoverflow.com/questions/59663153
复制相似问题