Created
June 24, 2020 02:40
-
-
Save myclau/f330ebd3e75aa7f745bd6de9f262e031 to your computer and use it in GitHub Desktop.
gitlab_api-powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get project id | |
$response=Invoke-WebRequest -Method GET -Headers @{"PRIVATE-TOKEN"="$apitoken";"Content-Type"="application/json"} -Uri "$gitremoteDomain/api/v4/projects" | |
$content=ConvertFrom-Json $([String]::new($response.Content)) | |
foreach ($c in $content){ | |
if($c.name -eq $projectname){ | |
$projectid = $c.id | |
break | |
} | |
} | |
$projectid | |
#create pipeline trigger | |
$response=Invoke-WebRequest -Method POST -Headers @{"PRIVATE-TOKEN"="$apitoken"} -Body @{description = 'source trigger'} -Uri "$gitremoteDomain/api/v4/projects/$projectid/triggers" | |
$content=ConvertFrom-Json $([String]::new($response.Content)) | |
$triggertoken=$content.token | |
$triggertoken |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment