How can I create multiple pipelines in Microsoft Azure DevOps by calling objects from single or multiple csv files?
How can the script pick up blank space from one of the excel columns? For example Folder Path
This is what I have so far.
Import-Csv -Path "C:Users*******Downloadsexcelnotes.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
The value for variables.
$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
This is the error message that I receive.
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
This is my csv file
2
Answers
If your CSV-file is stored in the variable
$pipelineVariables
then to pick up the Folder Path or Yaml Path (with whitespaces), you would simply:Example
Here is a quick example with your CSV-file and data:
First, by just importing it into a variable, I can see that in my case it did not properly create it into a Powershell array of objects:
To solve this
-Delimiter ";"
is being used:Example code snippet with
foreach
loop:I hope this helps!
Good luck!
You can use
-Delimiter ","
not;
forcsv import
.In addition, please also add
--project
for youraz pipelines create
command.Use command to login:
echo PAT | az devops login --organization https://dev.azure.com/orgname
.With below PowerShell script:
The script output:
The pipelines created:
PS: in my script, you can even remove
-Delimiter ","
for csv import, it’s also working.