在 azure pipeline 中输出变量
Output the variables in azure pipeline
我正在努力在我的天蓝色管道中获得电源 shell 的输出。
我试过在多个目录中发送它。 None 产生了预期的结果。
Echo 有效,我可以看到所有信息。现在我想在构建工件之前保存该数据并将其作为文件放在工作目录中。
以前从未这样做过,所以也不完全确定这是否是正确的方法。
Vars echo
根据您的要求,您需要将管道变量输出到Powershell中的txt文件。
您可以尝试使用以下PowerShell脚本:
"Bucket name = $(Bucketname), Bucket arn = $(Bucketarn)" | out-file -filepath $(build.sourcesdirectory)\vars.txt -append -width 200
例如:
variables:
Bucketname: 'test1'
Bucketarn: 'test2'
steps:
- powershell: '"Bucket name = $(Bucketname), Bucket arn = $(Bucketarn)" | out-file -filepath $(build.sourcesdirectory)\vars.txt -append -width 200'
displayName: 'PowerShell Script'
结果:
我正在努力在我的天蓝色管道中获得电源 shell 的输出。 我试过在多个目录中发送它。 None 产生了预期的结果。 Echo 有效,我可以看到所有信息。现在我想在构建工件之前保存该数据并将其作为文件放在工作目录中。
以前从未这样做过,所以也不完全确定这是否是正确的方法。
Vars echo
根据您的要求,您需要将管道变量输出到Powershell中的txt文件。
您可以尝试使用以下PowerShell脚本:
"Bucket name = $(Bucketname), Bucket arn = $(Bucketarn)" | out-file -filepath $(build.sourcesdirectory)\vars.txt -append -width 200
例如:
variables:
Bucketname: 'test1'
Bucketarn: 'test2'
steps:
- powershell: '"Bucket name = $(Bucketname), Bucket arn = $(Bucketarn)" | out-file -filepath $(build.sourcesdirectory)\vars.txt -append -width 200'
displayName: 'PowerShell Script'
结果: