Skip to content

Instantly share code, notes, and snippets.

@myclau
Created June 24, 2020 02:40
Show Gist options
  • Save myclau/f330ebd3e75aa7f745bd6de9f262e031 to your computer and use it in GitHub Desktop.
Save myclau/f330ebd3e75aa7f745bd6de9f262e031 to your computer and use it in GitHub Desktop.
gitlab_api-powershell
# 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