Powershell Trigger Gitlab CI With Variables

You can trigger with PowerShell GitLab-CI project with the below code.

Token and Ref must be filled.

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$Body = @{
"variables[variable1]" = "key"
"variables[variable2]" = "key"
"variables[variable3]" = "key"
"token" = "token"
"ref" = "branchref"
}
Invoke-RestMethod -Method Post -Uri "https://gitlab.example.com/api/v4/projects/id/trigger/pipeline" -Body $Body

Leave a Reply