-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew-BitbucketServerPullRequest.ps1
More file actions
40 lines (38 loc) · 1.51 KB
/
New-BitbucketServerPullRequest.ps1
File metadata and controls
40 lines (38 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Function New-BitbucketServerPullRequest {
param([Parameter(Mandatory=$false)] $Session = (Get-BitbucketSession),
[Parameter(Mandatory=$true)] $ProjectKey,
[Parameter(Mandatory=$true)] $Repository,
[Parameter(Mandatory=$true)] $BranchName,
[Parameter(Mandatory=$true)] $Description,
[Parameter(Mandatory=$true)] $Title,
[Parameter(Mandatory=$false)] [ValidateSet('OPEN','CLOSE')] $State = 'OPEN')
$payload = [PSCustomObject]@{
"title"=$Title
"description"=$Description
"state"=$State
"open"=$true
"closed"=$false
"fromRef"= [PSCustomObject]@{
"id"=$BranchName
"repository"= [PSCustomObject] @{
"slug"=$Repository
"project" = [PSCustomObject] @{"key"=$ProjectKey}
}
}
"toRef"= [PSCustomObject]@{
"id"="refs/heads/master"
"repository"=[PSCustomObject]@{
"slug"=$Repository
"project" =[PSCustomObject] @{"key"=$ProjectKey}
}
}
"locked"=$false
}
return ($payload | ConvertTo-Json | Invoke-RestMethod `
-Method POST `
-Uri "$($Session.BaseUrl)/rest/api/2.0/projects/$ProjectKey/repos/$Repository/pull-requests/" `
-Headers @{
"Content-Type"= "application/json"
Authorization = $Session.Authorization
}).values
}