How to trigger a GitLab pipeline with PowerShell : Using CSV file columns as arguments

Following scenario used to pass Azure Subscription ID list along with VM name list with a CSV file. Script will take the necessary parameters from CSV file and loop it through the GitLab pipeline.


Prerequisites 

1. Create a CSV file with two columns SUBSCRIPTION_ID & VM_NAME

2. You need to build the triggering pipeline via GitLab 


Script Steps

1. First you need to import your CSV File 

2. Go each excel rows

3. Tigger Pipeline


Import-Csv "<CSV_FilePath.csv>"| ForEach-Object {


   $subscription_id=$_.SUBSCRIPTION_ID

   $db_name=$_.VM_NAME

  

$postParams = @{


token='<GitLab_Proj_Token>';

ref='<Repo>';

"variables[subscription_id]"="$subscription_id";

"variables[db_name]"="$db_name"


 }

 

Invoke-WebRequest -Uri <GitLab_Pipeline_URI> -Method POST -Body $postParams

 

}



Post a Comment

0 Comments