Skip to content

Instantly share code, notes, and snippets.

@devlead
Created January 8, 2015 15:06
Show Gist options
  • Save devlead/190f2d4172413fff6e50 to your computer and use it in GitHub Desktop.
Save devlead/190f2d4172413fff6e50 to your computer and use it in GitHub Desktop.
Rough 1min add slack hook to all or certain repos PowerShell sample
$owner = "repo owner"
$body = @{type="POST";URL="slack hook"}
$cred=Get-Credential
$repos = Invoke-RestMethod -Credential $cred -Uri 'https://api.bitbucket.org/1.0/user/repositories/'
#All repos
$repos |Where-Object {$_.owner -eq $owner} | %{$uri="https://bitbucket.org/api$($_.resource_uri)/services/";Invoke-RestMethod -Uri $uri -Body $body -Method Post -Credential $cred}
#Filter repos
$repos |Where-Object {$_.owner -eq $owner -and $_.resource_uri -like "*needle*" } | %{$uri="https://bitbucket.org/api$($_.resource_uri)/services/";Invoke-RestMethod -Uri $uri -Body $body -Method Post -Credential $cred}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment