我有一个要求
for each top level folder in the azure repo:
print(foldername)
execute an entire set of tasks or stages of tasks around pylint and other various stuff我只是试着保存整个管道的文件夹名,但是有问题检索和保存它们.
我的yaml文件
trigger:
branches:
include: [ '*' ]
pool:
vmImage: ubuntu-latest
stages:
- stage: Gather_Folders
displayName: "Gather Folders"
jobs:
- job: "get_folder_names"
displayName: "Query Repo for folders"
steps:
- bash: echo $MODEL_NAMES
env:
MODEL_NAMES: $(ls -d -- */)输出
Generating script.
Script contents:
echo $MODEL_NAMES
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/jflsakjfldskjf.sh
$(ls -d -- */)
Finishing: Bash我检查了变量,变量只是接受文字命令本身,而不是它的输出。我在这里错过了什么?
我希望把文件夹名注入管道变量..。然后以某种方式对每个文件夹执行。平行的阶段或一组平行的阶段
发布于 2021-04-28 03:32:01
对于这个问题,Krzysztof Madej在这个ticket中给出了一个答案。要获取给定文件夹中的目录,可以使用以下脚本:
- task: PowerShell@2
displayName: Get all directories of $(Build.SourcesDirectory) and assign to variable
inputs:
targetType: 'inline'
script: |
$arr = Get-ChildItem '$(Build.SourcesDirectory)' |
Where-Object {$_.PSIsContainer} |
Foreach-Object {$_.Name}
echo "##vso[task.setvariable variable=arr;]$arr"
- task: PowerShell@2
displayName: List all directories from variable
inputs:
targetType: 'inline'
script: |
echo '$(arr)'https://stackoverflow.com/questions/67282694
复制相似问题