This repository was archived by the owner on Sep 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSet-GitLabProjectMilestone.ps1
More file actions
94 lines (78 loc) · 2.49 KB
/
Copy pathSet-GitLabProjectMilestone.ps1
File metadata and controls
94 lines (78 loc) · 2.49 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
function Set-GitLabProjectMilestone
{
<#
.SYNOPSIS
modifie a milestone
.DESCRIPTION
The Set-GitLabProjectMilestone function edits an existing Milestone in gitlab.
Use -PassThru to return the modified Milestone
.EXAMPLE
Set-GitLabProjectMilestone -ProjectID 20 -MilestoneID 1 -Description 'Release v1.0.0'
---------------------------------------------------------------
Sets the description of milestone 1 in project 20 to 'Release v1.0.0'
#>
[CmdletBinding()]
[Alias()]
[OutputType()]
Param
(
# ID of the porject
[Parameter(HelpMessage = 'ProjectID',
Mandatory = $true)]
[Alias('ID')]
[String]$ProjectID,
# ID of th milestone
[Parameter(HelpMessage = 'MilestoneID',
Mandatory = $true)]
[int]$MilestoneID,
# Title for the Milestone
[Parameter(Helpmessage = 'The title of an milestone', mandatory = $false)]
[string]$Title,
# Description for the milestone
[Parameter(Helpmessage = 'The description of the milestone',mandatory = $false)]
[string]$Description,
# Due Date for the milestone
[Parameter(Helpmessage = 'the due date of the milestone',mandatory = $false)]
[datetime]$dueDate,
# Set a state=-event for the milestone.
# the Milestone event can be 'close' or 'activate'
[Parameter(Helpmessage = 'stateevent for the milestone',mandatory = $false)]
[validateSet('close','activate')]
[Alias('StateEvent')]
[string]$State,
# Existing GitlabConnector Object, can be retrieved with Get-GitlabConnect
[Parameter(HelpMessage = 'Specify Existing GitlabConnector',
Mandatory = $false,
DontShow = $true)]
[psobject]$GitlabConnect = (Get-GitlabConnect),
# Return the modified Merge Request
[Parameter(HelpMessage = 'Passthru the created project',
Mandatory = $false)]
[switch]$PassThru
)
$httpmethod = 'put'
$apiurl = "projects/$([System.Web.HttpUtility]::UrlEncode($projectId))/milestones/$MilestoneID"
$parameters = @{
}
if($Title)
{
$parameters.title = $Title
}
if($Description)
{
$parameters.description = $Description
}
if($dueDate)
{
$parameters.'due_date' = $dueDate.tostring("yyyy'-'MM'-'dd")
}
if($State)
{
$parameters.'state_event' = $State
}
$modmilestone = $GitlabConnect.callapi($apiurl,$httpmethod,$parameters)
if($PassThru)
{
return $modmilestone
}
}