从LinuxVM到Azure管道的返回值

从LinuxVM到Azure管道的返回值,linux,azure,powershell,azure-devops,sh,Linux,Azure,Powershell,Azure Devops,Sh,Linux虚拟机是使用Azure管道创建的。在/data/config文件夹中动态创建了一个文件夹。要求将此文件夹的名称返回到DevOps管道。 调用shell脚本的powershell代码如下所示 Invoke-AzVMRunCommand -ResourceGroupName $ResourceGroupName -VMName $VirtualMachineName -CommandId RunShellScript -ScriptPath "$($PSScriptRoot)/s

Linux虚拟机是使用Azure管道创建的。在/data/config文件夹中动态创建了一个文件夹。要求将此文件夹的名称返回到DevOps管道。 调用shell脚本的powershell代码如下所示

Invoke-AzVMRunCommand -ResourceGroupName $ResourceGroupName -VMName $VirtualMachineName -CommandId RunShellScript -ScriptPath "$($PSScriptRoot)/scripts/$PatchScript"  -Parameter @{InputConf=$ReplInputConf} 
我在shell脚本中完成了以下操作,文件夹名被写入a.txt

sudo -u $User find /data/config -maxdepth 1 -type d | sed 's/.*\///' >>  /log/a.txt
sudo -u $User sed -i "/^\s*$/d" /log/a.txt 
如何将a.txt中的字符串返回到管道


谢谢

您可以尝试使用脚本获取txt文件的内容,并为内容设置变量
$var
。然后使用在taskcontext的变量服务中设置另一个变量。此变量作为环境变量公开给以下任务

echo "##vso[task.setvariable variable=testvar;]$var"

你查过我的答复了吗?有帮助吗?