如何通过从单个或多个 csv 文件调用对象来在 Microsoft Azure DevOps 中创建多个管道?
脚本如何从 Excel 列之一中拾取空白区域?例如文件夹路径
这就是我目前所拥有的。
Import-Csv -Path "C:\Users\*******\Downloads\excel\notes.csv"
$pipelineName = $pipelineVariables.name
$pipelineFolderPath = $pipelineVariables.FolderPath
$pipelineDescription = $pipelineVariables.Description
$pipelineRepostiory = $pipelineVariables.Repository
$pipelineBranch = $pipelineVariables.Branch
$pipelineYamlPath = $pipelineVariables.YamlPath
az pipelines create --name $pipelineName --folder-path $pipelineFolderPath --description $pipelineDescription --repository $pipelineRepostiory --branch $pipelineBranch --yml-path $pipelineYamlPath
变量的值。
$pipelineName = $pipelineVariables.name
$pipelineFolderPath = $pipelineVariables.FolderPath
$pipelineDescription = $pipelineVariables.Description
$pipelineRepostiory = $pipelineVariables.Repository
$pipelineBranch = $pipelineVariables.Branch
$pipelineYamlPath = $pipelineVariables.YamlPath
Name : test-ci
FolderPath : build
Description : test ci pipeline
Repository : https://dev.azure.com/******/*****/_git/******
Branch : prod
Yaml Path : ./yaml/build.yml
这是我收到的错误消息。
az : ERROR: argument --folder-path: expected one argument
At line:1 char:1
+ az pipelines create --name $pipelineName --folder-path $pipelineFolde ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (ERROR: argument...ed one argument:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
这是我的 csv 文件
如果您的 CSV 文件存储在变量
$pipelineVariables
中,那么要选择文件夹路径或 Yaml 路径(带空格),您只需:
$pipelineFolderPath = $pipelineVariables."Folder Path"
$pipelineYamlPath = $pipelineVariables."Yaml Path"
这是包含 CSV 文件和数据的简单示例:
$Csv = Import-Csv .\CreatePipelineExample.csv -Delimiter ";"
foreach ($Pipeline in $Csv) {
az pipelines create --name $Pipeline.Name --folder-path $Pipeline."Folder Path" --description $Pipeline.Description --repository $Pipeline.Repository --branch $Pipeline.Branch --yml-path $Pipeline."Yaml Path"
}
我希望这有帮助! 祝你好运!