Created
January 8, 2015 15:06
-
-
Save devlead/190f2d4172413fff6e50 to your computer and use it in GitHub Desktop.
Rough 1min add slack hook to all or certain repos PowerShell sample
This file contains hidden or 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
$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