gitlab 4.12.0 → 4.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +24 -16
- data/lib/gitlab/api.rb +2 -0
- data/lib/gitlab/cli.rb +6 -5
- data/lib/gitlab/cli_helpers.rb +10 -16
- data/lib/gitlab/client/build_variables.rb +17 -12
- data/lib/gitlab/client/commits.rb +42 -5
- data/lib/gitlab/client/container_registry.rb +1 -1
- data/lib/gitlab/client/epic_issues.rb +23 -0
- data/lib/gitlab/client/epics.rb +73 -0
- data/lib/gitlab/client/group_badges.rb +88 -0
- data/lib/gitlab/client/group_labels.rb +1 -1
- data/lib/gitlab/client/groups.rb +247 -2
- data/lib/gitlab/client/issue_links.rb +48 -0
- data/lib/gitlab/client/issues.rb +12 -1
- data/lib/gitlab/client/jobs.rb +91 -8
- data/lib/gitlab/client/keys.rb +11 -0
- data/lib/gitlab/client/labels.rb +1 -1
- data/lib/gitlab/client/merge_request_approvals.rb +155 -2
- data/lib/gitlab/client/merge_requests.rb +76 -4
- data/lib/gitlab/client/merge_trains.rb +55 -0
- data/lib/gitlab/client/notes.rb +27 -0
- data/lib/gitlab/client/packages.rb +95 -0
- data/lib/gitlab/client/pipeline_schedules.rb +16 -4
- data/lib/gitlab/client/pipelines.rb +37 -0
- data/lib/gitlab/client/project_exports.rb +54 -0
- data/lib/gitlab/client/project_releases.rb +11 -0
- data/lib/gitlab/client/projects.rb +119 -7
- data/lib/gitlab/client/remote_mirrors.rb +51 -0
- data/lib/gitlab/client/repositories.rb +56 -1
- data/lib/gitlab/client/repository_files.rb +16 -0
- data/lib/gitlab/client/resource_state_events.rb +57 -0
- data/lib/gitlab/client/runners.rb +126 -21
- data/lib/gitlab/client/search.rb +5 -1
- data/lib/gitlab/client/user_snippets.rb +114 -0
- data/lib/gitlab/client/users.rb +267 -12
- data/lib/gitlab/client.rb +16 -2
- data/lib/gitlab/configuration.rb +1 -1
- data/lib/gitlab/error.rb +36 -1
- data/lib/gitlab/headers/page_links.rb +37 -0
- data/lib/gitlab/headers/total.rb +29 -0
- data/lib/gitlab/help.rb +8 -8
- data/lib/gitlab/objectified_hash.rb +23 -7
- data/lib/gitlab/paginated_response.rb +29 -40
- data/lib/gitlab/request.rb +35 -21
- data/lib/gitlab/shell_history.rb +2 -2
- data/lib/gitlab/version.rb +1 -1
- data/lib/gitlab.rb +17 -6
- metadata +24 -48
- data/lib/gitlab/page_links.rb +0 -35
|
@@ -31,7 +31,65 @@ class Gitlab::Client
|
|
|
31
31
|
post("/projects/#{url_encode project}/approvals", body: options)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
# Gets MR Approval Rules for a project
|
|
35
|
+
#
|
|
36
|
+
# @example
|
|
37
|
+
# Gitlab.project_merge_request_approval_rules(1)
|
|
38
|
+
#
|
|
39
|
+
# @param [Integer] project The ID of a project.
|
|
40
|
+
# @return [Gitlab::ObjectifiedHash] MR approval rules for the project
|
|
41
|
+
def project_merge_request_approval_rules(project)
|
|
42
|
+
get("/projects/#{url_encode project}/approval_rules")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Create MR Approval Rule for a project
|
|
46
|
+
#
|
|
47
|
+
# @example
|
|
48
|
+
# Gitlab.create_project_merge_request_approval_rule(1, {name: "security", approvals_required: 1})
|
|
49
|
+
#
|
|
50
|
+
# @param [Integer] project(required) The ID of a project.
|
|
51
|
+
# @option options [String] :name(required) The name of the approval rule
|
|
52
|
+
# @option options [Integer] :approvals_required(required) The number of required approvals for this rule
|
|
53
|
+
# @option options [Array] :user_ids(optional) The ids of users as approvers
|
|
54
|
+
# @option options [Array] :group_ids(optional) The ids of groups as approvers
|
|
55
|
+
# @option options [Array] :protected_branch_ids(optional) The ids of protected branches to scope the rule by
|
|
56
|
+
# @return [Gitlab::ObjectifiedHash] New MR approval rule
|
|
57
|
+
def create_project_merge_request_approval_rule(project, options = {})
|
|
58
|
+
post("/projects/#{url_encode project}/approval_rules", body: options)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Update MR Approval Rule for a project
|
|
62
|
+
#
|
|
63
|
+
# @example
|
|
64
|
+
# Gitlab.update_project_merge_request_approval_rule(1, {name: "security", approvals_required: 2})
|
|
65
|
+
#
|
|
66
|
+
# @param [Integer] project(required) The ID of a project.
|
|
67
|
+
# @param [Integer] approval_rule_id(required) The ID of a project Approval Rule
|
|
68
|
+
# @option options [String] :name(required) The name of the approval rule
|
|
69
|
+
# @option options [Integer] :approvals_required(required) The number of required approvals for this rule
|
|
70
|
+
# @option options [Array] :user_ids(optional) The ids of users as approvers
|
|
71
|
+
# @option options [Array] :group_ids(optional) The ids of groups as approvers
|
|
72
|
+
# @option options [Array] :protected_branch_ids(optional) The ids of protected branches to scope the rule by
|
|
73
|
+
# @return [Gitlab::ObjectifiedHash] Updated MR approval rule
|
|
74
|
+
def update_project_merge_request_approval_rule(project, approval_rule_id, options = {})
|
|
75
|
+
put("/projects/#{url_encode project}/approval_rules/#{approval_rule_id}", body: options)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Delete MR Approval Rule for a project
|
|
79
|
+
#
|
|
80
|
+
# @example
|
|
81
|
+
# Gitlab.delete_project_merge_request_approval_rule(1, 1)
|
|
82
|
+
#
|
|
83
|
+
# @param [Integer] project(required) The ID of a project.
|
|
84
|
+
# @param [Integer] approval_rule_id(required) The ID of a approval rule
|
|
85
|
+
# @return [void] This API call returns an empty response body
|
|
86
|
+
def delete_project_merge_request_approval_rule(project, approval_rule_id)
|
|
87
|
+
delete("/projects/#{url_encode project}/approval_rules/#{approval_rule_id}")
|
|
88
|
+
end
|
|
89
|
+
|
|
34
90
|
# Change allowed approvers and approver groups for a project
|
|
91
|
+
# @deprecated Since Gitlab 13.12 /approvers endpoints are removed!!!
|
|
92
|
+
# See Gitlab.create_project_merge_request_approval_rule
|
|
35
93
|
#
|
|
36
94
|
# @example
|
|
37
95
|
# Gitlab.edit_project_approvers(1, {approver_ids: [5], approver_groups: [1]})
|
|
@@ -70,6 +128,8 @@ class Gitlab::Client
|
|
|
70
128
|
end
|
|
71
129
|
|
|
72
130
|
# Change allowed approvers and approver groups for a merge request
|
|
131
|
+
# @deprecated Since Gitlab 13.12 /approvers endpoints are removed!!!
|
|
132
|
+
# See Gitlab.create_merge_request_level_rule
|
|
73
133
|
#
|
|
74
134
|
# @example
|
|
75
135
|
# Gitlab.edit_merge_request_approvers(1, 5, {approver_ids: [5], approver_groups: [1]})
|
|
@@ -83,6 +143,86 @@ class Gitlab::Client
|
|
|
83
143
|
put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvers", body: options)
|
|
84
144
|
end
|
|
85
145
|
|
|
146
|
+
# Create merge request level rule
|
|
147
|
+
#
|
|
148
|
+
# @example
|
|
149
|
+
# Gitlab.create_merge_request_level_rule(1, 2, {
|
|
150
|
+
# name: "devs",
|
|
151
|
+
# approvals_required: 2,
|
|
152
|
+
# approval_project_rule_id: 99,
|
|
153
|
+
# user_ids: [3, 4],
|
|
154
|
+
# group_ids: [5, 6],
|
|
155
|
+
# })
|
|
156
|
+
#
|
|
157
|
+
# Important: When approval_project_rule_id is set, the name, users and groups of project-level rule are copied.
|
|
158
|
+
# The approvals_required specified is used.
|
|
159
|
+
#
|
|
160
|
+
# @param [Integer] project(required) The ID of a project.
|
|
161
|
+
# @param [Integer] merge_request(required) The IID of a merge request.
|
|
162
|
+
# @option options [String] :name(required) The name of the approval rule
|
|
163
|
+
# @option options [Integer] :approvals_required(required) The number of required approvals for this rule
|
|
164
|
+
# @option options [Integer] :approval_project_rule_id(optional) The ID of a project-level approval rule
|
|
165
|
+
# @option options [Array] :user_ids(optional) The ids of users as approvers
|
|
166
|
+
# @option options [Array] :group_ids(optional) The ids of groups as approvers
|
|
167
|
+
# @return [Gitlab::ObjectifiedHash] New MR level approval rule
|
|
168
|
+
def create_merge_request_level_rule(project, merge_request, options = {})
|
|
169
|
+
post("/projects/#{url_encode project}/merge_requests/#{merge_request}/approval_rules", body: options)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Get merge request level rule
|
|
173
|
+
#
|
|
174
|
+
# @example
|
|
175
|
+
# Gitlab.merge_request_level_rule(1, 2)
|
|
176
|
+
#
|
|
177
|
+
# @param [Integer] project(required) The ID of a project.
|
|
178
|
+
# @param [Integer] merge_request(required) The IID of a merge request.
|
|
179
|
+
# @return [Gitlab::ObjectifiedHash] New MR level approval rule
|
|
180
|
+
def merge_request_level_rule(project, merge_request)
|
|
181
|
+
get("/projects/#{url_encode project}/merge_requests/#{merge_request}/approval_rules")
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Update merge request level rule
|
|
185
|
+
#
|
|
186
|
+
# @example
|
|
187
|
+
# Gitlab.update_merge_request_level_rule(1, 2, 69, {
|
|
188
|
+
# name: "devs",
|
|
189
|
+
# approvals_required: 2,
|
|
190
|
+
# user_ids: [3, 4],
|
|
191
|
+
# group_ids: [5, 6],
|
|
192
|
+
# })
|
|
193
|
+
#
|
|
194
|
+
# Important: Approvers and groups not in the users/groups parameters are removed
|
|
195
|
+
# Important: Updating a report_approver or code_owner rule is not allowed.
|
|
196
|
+
# These are system generated rules.
|
|
197
|
+
#
|
|
198
|
+
# @param [Integer] project(required) The ID of a project.
|
|
199
|
+
# @param [Integer] merge_request(required) The IID of a merge request.
|
|
200
|
+
# @param [Integer] appr_rule_id(required) The ID of a approval rule
|
|
201
|
+
# @option options [String] :name(required) The name of the approval rule
|
|
202
|
+
# @option options [Integer] :approvals_required(required) The number of required approvals for this rule
|
|
203
|
+
# @option options [Array] :user_ids(optional) The ids of users as approvers
|
|
204
|
+
# @option options [Array] :group_ids(optional) The ids of groups as approvers
|
|
205
|
+
# @return [Gitlab::ObjectifiedHash] Updated MR level approval rule
|
|
206
|
+
def update_merge_request_level_rule(project, merge_request, appr_rule_id, options = {})
|
|
207
|
+
put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approval_rules/#{appr_rule_id}", body: options)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# Delete merge request level rule
|
|
211
|
+
#
|
|
212
|
+
# @example
|
|
213
|
+
# Gitlab.delete_merge_request_level_rule(1, 2, 69)
|
|
214
|
+
#
|
|
215
|
+
# Important: Deleting a report_approver or code_owner rule is not allowed.
|
|
216
|
+
# These are system generated rules.
|
|
217
|
+
#
|
|
218
|
+
# @param [Integer] project(required) The ID of a project.
|
|
219
|
+
# @param [Integer] merge_request(required) The IID of a merge request.
|
|
220
|
+
# @param [Integer] appr_rule_id(required) The ID of a approval rule
|
|
221
|
+
# @return [void] This API call returns an empty response body
|
|
222
|
+
def delete_merge_request_level_rule(project, merge_request, appr_rule_id)
|
|
223
|
+
delete("/projects/#{url_encode project}/merge_requests/#{merge_request}/approval_rules/#{appr_rule_id}")
|
|
224
|
+
end
|
|
225
|
+
|
|
86
226
|
# Approve a merge request
|
|
87
227
|
#
|
|
88
228
|
# @example
|
|
@@ -104,9 +244,22 @@ class Gitlab::Client
|
|
|
104
244
|
#
|
|
105
245
|
# @param [Integer] project(required) The ID of a project.
|
|
106
246
|
# @param [Integer] merge_request(required) The IID of a merge request.
|
|
247
|
+
# @option options [String] :sudo(optional) The username of the user you want to remove the approval for
|
|
107
248
|
# @return [void] This API call returns an empty response body.
|
|
108
|
-
def unapprove_merge_request(project, merge_request)
|
|
109
|
-
post("/projects/#{url_encode project}/merge_requests/#{merge_request}/unapprove")
|
|
249
|
+
def unapprove_merge_request(project, merge_request, options = {})
|
|
250
|
+
post("/projects/#{url_encode project}/merge_requests/#{merge_request}/unapprove", body: options)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Get the approval state of merge requests
|
|
254
|
+
#
|
|
255
|
+
# @example
|
|
256
|
+
# Gitlab.merge_request_approval_state(5, 36)
|
|
257
|
+
#
|
|
258
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
259
|
+
# @param [Integer] id The ID of a merge request.
|
|
260
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
261
|
+
def merge_request_approval_state(project, id)
|
|
262
|
+
get("/projects/#{url_encode project}/merge_requests/#{id}/approval_state")
|
|
110
263
|
end
|
|
111
264
|
end
|
|
112
265
|
end
|
|
@@ -35,12 +35,16 @@ class Gitlab::Client
|
|
|
35
35
|
#
|
|
36
36
|
# @example
|
|
37
37
|
# Gitlab.merge_request(5, 36)
|
|
38
|
+
# Gitlab.merge_request(5, 36, { include_diverged_commits_count: true })
|
|
38
39
|
#
|
|
39
40
|
# @param [Integer, String] project The ID or name of a project.
|
|
40
41
|
# @param [Integer] id The ID of a merge request.
|
|
42
|
+
# @option options [Boolean] :render_html If true response includes rendered HTML for title and description.
|
|
43
|
+
# @option options [Boolean] :include_diverged_commits_count If true response includes the commits behind the target branch.
|
|
44
|
+
# @option options [Boolean] :include_rebase_in_progress If true response includes whether a rebase operation is in progress.
|
|
41
45
|
# @return <Gitlab::ObjectifiedHash]
|
|
42
|
-
def merge_request(project, id)
|
|
43
|
-
get("/projects/#{url_encode project}/merge_requests/#{id}")
|
|
46
|
+
def merge_request(project, id, options = {})
|
|
47
|
+
get("/projects/#{url_encode project}/merge_requests/#{id}", query: options)
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
# Gets a list of merge request pipelines.
|
|
@@ -55,6 +59,25 @@ class Gitlab::Client
|
|
|
55
59
|
get("/projects/#{url_encode project}/merge_requests/#{id}/pipelines")
|
|
56
60
|
end
|
|
57
61
|
|
|
62
|
+
# Create a new pipeline for a merge request.
|
|
63
|
+
# A pipeline created via this endpoint doesnt run a regular branch/tag pipeline.
|
|
64
|
+
# It requires .gitlab-ci.yml to be configured with only: [merge_requests] to create jobs.
|
|
65
|
+
#
|
|
66
|
+
# The new pipeline can be:
|
|
67
|
+
#
|
|
68
|
+
# A detached merge request pipeline.
|
|
69
|
+
# A pipeline for merged results if the project setting is enabled.
|
|
70
|
+
#
|
|
71
|
+
# @example
|
|
72
|
+
# Gitlab.create_merge_request_pipeline(5, 36)
|
|
73
|
+
#
|
|
74
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
75
|
+
# @param [Integer] iid The internal ID of a merge request.
|
|
76
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
77
|
+
def create_merge_request_pipeline(project, iid)
|
|
78
|
+
post("/projects/#{url_encode project}/merge_requests/#{iid}/pipelines")
|
|
79
|
+
end
|
|
80
|
+
|
|
58
81
|
# Get a list of merge request participants.
|
|
59
82
|
#
|
|
60
83
|
# @example
|
|
@@ -81,8 +104,14 @@ class Gitlab::Client
|
|
|
81
104
|
# @option options [String] :source_branch (required) The source branch name.
|
|
82
105
|
# @option options [String] :target_branch (required) The target branch name.
|
|
83
106
|
# @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
|
|
107
|
+
# @option options [Array<Integer>] :assignee_ids (optional) The ID of the user(s) to assign the MR to. Set to 0 or provide an empty value to unassign all assignees.
|
|
108
|
+
# @option options [String] :description (optional) Description of MR. Limited to 1,048,576 characters.
|
|
84
109
|
# @option options [Integer] :target_project_id (optional) The target project ID.
|
|
85
110
|
# @option options [String] :labels (optional) Labels as a comma-separated list.
|
|
111
|
+
# @option options [Integer] :milestone_id (optional) The global ID of a milestone
|
|
112
|
+
# @option options [Boolean] :remove_source_branch (optional) Flag indicating if a merge request should remove the source branch when merging
|
|
113
|
+
# @option options [Boolean] :allow_collaboration (optional) Allow commits from members who can merge to the target branch
|
|
114
|
+
# @option options [Boolean] :squash (optional) Squash commits into a single commit when merging
|
|
86
115
|
# @return [Gitlab::ObjectifiedHash] Information about created merge request.
|
|
87
116
|
def create_merge_request(project, title, options = {})
|
|
88
117
|
body = { title: title }.merge(options)
|
|
@@ -115,7 +144,12 @@ class Gitlab::Client
|
|
|
115
144
|
# @param [Integer, String] project The ID or name of a project.
|
|
116
145
|
# @param [Integer] id The ID of a merge request.
|
|
117
146
|
# @param [Hash] options A customizable set of options.
|
|
118
|
-
# @option options [String] :merge_commit_message Custom merge commit message
|
|
147
|
+
# @option options [String] :merge_commit_message(optional) Custom merge commit message
|
|
148
|
+
# @option options [String] :squash_commit_message(optional) Custom squash commit message
|
|
149
|
+
# @option options [Boolean] :squash(optional) if true the commits will be squashed into a single commit on merge
|
|
150
|
+
# @option options [Boolean] :should_remove_source_branch(optional) if true removes the source branch
|
|
151
|
+
# @option options [Boolean] :merge_when_pipeline_succeeds(optional) if true the MR is merged when the pipeline succeeds
|
|
152
|
+
# @option options [String] :sha(optional) if present, then this SHA must match the HEAD of the source branch, otherwise the merge will fail
|
|
119
153
|
# @return [Gitlab::ObjectifiedHash] Information about updated merge request.
|
|
120
154
|
def accept_merge_request(project, id, options = {})
|
|
121
155
|
put("/projects/#{url_encode project}/merge_requests/#{id}/merge", body: options)
|
|
@@ -153,7 +187,7 @@ class Gitlab::Client
|
|
|
153
187
|
# @param [Integer] project The ID of a project
|
|
154
188
|
# @param [Integer] iid The internal ID of a merge request
|
|
155
189
|
def merge_request_closes_issues(project_id, merge_request_iid)
|
|
156
|
-
get("/projects/#{project_id}/merge_requests/#{merge_request_iid}/closes_issues")
|
|
190
|
+
get("/projects/#{url_encode project_id}/merge_requests/#{merge_request_iid}/closes_issues")
|
|
157
191
|
end
|
|
158
192
|
|
|
159
193
|
# Subscribes to a merge request.
|
|
@@ -298,6 +332,30 @@ class Gitlab::Client
|
|
|
298
332
|
delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}")
|
|
299
333
|
end
|
|
300
334
|
|
|
335
|
+
# Delete a merge request
|
|
336
|
+
#
|
|
337
|
+
# @example
|
|
338
|
+
# Gitlab.delete_merge_request(5, 1)
|
|
339
|
+
# Gitlab.delete_merge_request('gitlab', 1)
|
|
340
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
341
|
+
# @param [Integer] id The ID of a merge request.
|
|
342
|
+
# @return [Gitlab::ObjectifiedHash] An empty response.
|
|
343
|
+
def delete_merge_request(project, merge_request_id)
|
|
344
|
+
delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}")
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
# Gets a list of merge request diffs
|
|
348
|
+
#
|
|
349
|
+
# @example
|
|
350
|
+
# Gitlab.merge_request_diffs(5, 1)
|
|
351
|
+
# Gitlab.merge_request_diffs('gitlab', 1)
|
|
352
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
353
|
+
# @param [Integer] id The ID of a merge request.
|
|
354
|
+
# @return [Gitlab::ObjectifiedHash] A list of the merge request diffs.
|
|
355
|
+
def merge_request_diffs(project, merge_request_id)
|
|
356
|
+
get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/diffs")
|
|
357
|
+
end
|
|
358
|
+
|
|
301
359
|
# Gets a list of merge request diff versions
|
|
302
360
|
#
|
|
303
361
|
# @example
|
|
@@ -322,5 +380,19 @@ class Gitlab::Client
|
|
|
322
380
|
def merge_request_diff_version(project, merge_request_id, version_id)
|
|
323
381
|
get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/versions/#{version_id}")
|
|
324
382
|
end
|
|
383
|
+
|
|
384
|
+
# Rebase a merge request.
|
|
385
|
+
#
|
|
386
|
+
# @example
|
|
387
|
+
# Gitlab.rebase_merge_request(5, 42, { skip_ci: true })
|
|
388
|
+
#
|
|
389
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
390
|
+
# @param [Integer] id The ID of a merge request.
|
|
391
|
+
# @param [Hash] options A customizable set of options.
|
|
392
|
+
# @option options [String] :skip_ci Set to true to skip creating a CI pipeline
|
|
393
|
+
# @return [Gitlab::ObjectifiedHash] Rebase progress status
|
|
394
|
+
def rebase_merge_request(project, id, options = {})
|
|
395
|
+
put("/projects/#{url_encode project}/merge_requests/#{id}/rebase", body: options)
|
|
396
|
+
end
|
|
325
397
|
end
|
|
326
398
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Gitlab::Client
|
|
4
|
+
# Defines methods related to merge trains.
|
|
5
|
+
# @see https://docs.gitlab.com/ee/api/merge_trains.html
|
|
6
|
+
module MergeTrains
|
|
7
|
+
# Get list of merge trains for a project.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# Gitlab.merge_trains(1, scope: :active, sort: :asc)
|
|
11
|
+
#
|
|
12
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
13
|
+
# @param [Hash] options A customizable set of options.
|
|
14
|
+
# @option options [String] :scope The scope of merge trains to return, one of: :active, :complete
|
|
15
|
+
# @option options [String] :sort Sort by created_at either 'asc' or 'desc'
|
|
16
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
17
|
+
def merge_trains(project, options = {})
|
|
18
|
+
get("/projects/#{url_encode project}/merge_trains", query: options)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Get all merge requests added to a merge train for the requested target branch.
|
|
22
|
+
#
|
|
23
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
24
|
+
# @param [String] target_branch The target branch of the merge train.
|
|
25
|
+
# @param [Hash] options A customizable set of options.
|
|
26
|
+
# @option options [String] :scope The scope of merge trains to return, one of: :active, :complete
|
|
27
|
+
# @option options [String] :sort Sort by created_at either 'asc' or 'desc'
|
|
28
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
29
|
+
def merge_train_merge_requests(project, target_branch, options = {})
|
|
30
|
+
get("/projects/#{url_encode project}/merge_trains/#{target_branch}", query: options)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Get merge train information for the requested merge request.
|
|
34
|
+
#
|
|
35
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
36
|
+
# @param [Integer] merge_request_iid The IID of the merge request.
|
|
37
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
38
|
+
def merge_train_status(project, merge_request_iid)
|
|
39
|
+
get("/projects/#{url_encode project}/merge_trains/merge_requests/#{merge_request_iid}")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Add a merge request to the merge train targeting the merge request’s target branch.
|
|
43
|
+
#
|
|
44
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
45
|
+
# @param [Integer] merge_request_iid The IID of the merge request.
|
|
46
|
+
# @param [Hash] options A customizable set of options.
|
|
47
|
+
# @option options [Boolean] :when_pipeline_succeeds Add merge request to merge train when pipeline succeeds.
|
|
48
|
+
# @option options [String] :sha If present, the SHA must match the HEAD of the source branch, otherwise the merge fails.
|
|
49
|
+
# @option options [Boolean] :squash If true, the commits are squashed into a single commit on merge.
|
|
50
|
+
# @return [Array<Gitlab::ObjectifiedHash>] <description>
|
|
51
|
+
def add_merge_request_to_merge_train(project, merge_request_iid, options = {})
|
|
52
|
+
post("/projects/#{url_encode project}/merge_trains/merge_requests/#{merge_request_iid}", query: options)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
data/lib/gitlab/client/notes.rb
CHANGED
|
@@ -60,6 +60,20 @@ class Gitlab::Client
|
|
|
60
60
|
end
|
|
61
61
|
alias merge_request_comments merge_request_notes
|
|
62
62
|
|
|
63
|
+
# Gets a list of notes for an epic.
|
|
64
|
+
#
|
|
65
|
+
# @example
|
|
66
|
+
# Gitlab.epic_notes(5, 10)
|
|
67
|
+
#
|
|
68
|
+
# @param [Integer] project The ID of a group.
|
|
69
|
+
# @param [Integer] epic The ID of an epic.
|
|
70
|
+
# @option options [Integer] :page The page number.
|
|
71
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
72
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
73
|
+
def epic_notes(group, epic, options = {})
|
|
74
|
+
get("/groups/#{url_encode group}/epics/#{epic}/notes", query: options)
|
|
75
|
+
end
|
|
76
|
+
|
|
63
77
|
# Gets a single wall note.
|
|
64
78
|
#
|
|
65
79
|
# @example
|
|
@@ -162,6 +176,19 @@ class Gitlab::Client
|
|
|
162
176
|
end
|
|
163
177
|
alias create_merge_request_comment create_merge_request_note
|
|
164
178
|
|
|
179
|
+
# Creates a new epic note.
|
|
180
|
+
#
|
|
181
|
+
# @example
|
|
182
|
+
# Gitlab.create_epic_note(6, 1, 'Adding a note to my epic.')
|
|
183
|
+
#
|
|
184
|
+
# @param [Integer, String] group The ID or name of a group.
|
|
185
|
+
# @param [Integer] epic The ID of an epic.
|
|
186
|
+
# @param [String] body The body of a note.
|
|
187
|
+
# @return [Gitlab::ObjectifiedHash] Information about created note.
|
|
188
|
+
def create_epic_note(group, epic, body)
|
|
189
|
+
post("/groups/#{url_encode group}/epics/#{epic}/notes", body: { body: body })
|
|
190
|
+
end
|
|
191
|
+
|
|
165
192
|
# Deletes a wall note.
|
|
166
193
|
#
|
|
167
194
|
# @example
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Gitlab::Client
|
|
4
|
+
# Defines methods related to GitLab Packages.
|
|
5
|
+
# @see https://docs.gitlab.com/ee/api/packages.html
|
|
6
|
+
module Packages
|
|
7
|
+
# Gets a list of project packages.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# Gitlab.project_packages(5)
|
|
11
|
+
# Gitlab.project_packages(5, { package_type: 'npm', sort: 'desc' })
|
|
12
|
+
#
|
|
13
|
+
# @param [Integer, String] :project the ID or name of a project.
|
|
14
|
+
# @param [Hash] options A customizable set of options.
|
|
15
|
+
# @options options [String] :order_by The field to use as order. One of created_at (default), name, version, or type.
|
|
16
|
+
# @options options [String] :sort The direction of the order, either asc (default) for ascending order or desc for descending order.
|
|
17
|
+
# @options options [String] :package_type Filter the returned packages by type. One of conan, maven, npm, pypi, composer, nuget, helm, terraform_module, or golang.
|
|
18
|
+
# @options options [String] :package_name Filter the project packages with a fuzzy search by name.
|
|
19
|
+
# @options options [String] :include_versionless When set to true, versionless packages are included in the response.
|
|
20
|
+
# @options options [String] :status Filter the returned packages by status. One of default (default), hidden, processing, error, or pending_destruction.
|
|
21
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
22
|
+
def project_packages(project, options = {})
|
|
23
|
+
get("/projects/#{url_encode project}/packages", query: options)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Gets a list of project packages.
|
|
27
|
+
#
|
|
28
|
+
# @example
|
|
29
|
+
# Gitlab.group_packages(5)
|
|
30
|
+
# Gitlab.group_packages(5, { package_type: 'npm', sort: 'desc' })
|
|
31
|
+
#
|
|
32
|
+
# @param [Integer, String] project the ID or name of a project.
|
|
33
|
+
# @param [Hash] options A customizable set of options.
|
|
34
|
+
# @options options [String] :exclude_subgroups If the parameter is included as true, packages from projects from subgroups are not listed. Default is false.
|
|
35
|
+
# @options options [String] :order_by The field to use as order. One of created_at (default), name, version, or type.
|
|
36
|
+
# @options options [String] :sort The direction of the order, either asc (default) for ascending order or desc for descending order.
|
|
37
|
+
# @options options [String] :package_type Filter the returned packages by type. One of conan, maven, npm, pypi, composer, nuget, helm, terraform_module, or golang.
|
|
38
|
+
# @options options [String] :package_name Filter the project packages with a fuzzy search by name.
|
|
39
|
+
# @options options [String] :include_versionless When set to true, versionless packages are included in the response.
|
|
40
|
+
# @options options [String] :status Filter the returned packages by status. One of default (default), hidden, processing, error, or pending_destruction.
|
|
41
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
42
|
+
def group_packages(group, options = {})
|
|
43
|
+
get("/groups/#{url_encode group}/packages", query: options)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Get a single project package.
|
|
47
|
+
#
|
|
48
|
+
# @example
|
|
49
|
+
# Gitlab.project_package(5, 3)
|
|
50
|
+
#
|
|
51
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
52
|
+
# @param [Integer] id ID of a package.
|
|
53
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
54
|
+
def project_package(project, id)
|
|
55
|
+
get("/projects/#{url_encode project}/packages/#{id}")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Get a list of package files of a single package.
|
|
59
|
+
#
|
|
60
|
+
# @example
|
|
61
|
+
# Gitlab.project_package_files(5, 3)
|
|
62
|
+
#
|
|
63
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
64
|
+
# @param [Integer] id ID of a package.
|
|
65
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
66
|
+
def project_package_files(project, id)
|
|
67
|
+
get("/projects/#{url_encode project}/packages/#{id}/package_files")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Deletes a project package.
|
|
71
|
+
#
|
|
72
|
+
# @example
|
|
73
|
+
# Gitlab.delete_project_package(5, 3)
|
|
74
|
+
#
|
|
75
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
76
|
+
# @param [Integer] id ID of a package.
|
|
77
|
+
# @return [void] This API call returns an empty response body.
|
|
78
|
+
def delete_project_package(project, id)
|
|
79
|
+
delete("/projects/#{url_encode project}/packages/#{id}")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Delete a package file.
|
|
83
|
+
#
|
|
84
|
+
# @example
|
|
85
|
+
# Gitlab.delete_project_file(5, 3, 1)
|
|
86
|
+
#
|
|
87
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
88
|
+
# @param [Integer] package_id ID of a package.
|
|
89
|
+
# @param [Integer] file_id ID of a package file.
|
|
90
|
+
# @return [void] This API call returns an empty response body.
|
|
91
|
+
def delete_project_package_file(project, package_id, file_id)
|
|
92
|
+
delete("/projects/#{url_encode project}/packages/#{package_id}/package_files/#{file_id}")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -44,7 +44,7 @@ class Gitlab::Client
|
|
|
44
44
|
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
|
|
45
45
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
46
46
|
def create_pipeline_schedule(project, options = {})
|
|
47
|
-
post("/projects/#{url_encode project}/pipeline_schedules",
|
|
47
|
+
post("/projects/#{url_encode project}/pipeline_schedules", body: options)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
# Updates the pipeline schedule of a project.
|
|
@@ -62,7 +62,7 @@ class Gitlab::Client
|
|
|
62
62
|
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
|
|
63
63
|
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule.
|
|
64
64
|
def edit_pipeline_schedule(project, pipeline_schedule_id, options = {})
|
|
65
|
-
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}",
|
|
65
|
+
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}", body: options)
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
# Take ownership of a pipeline schedule.
|
|
@@ -77,6 +77,18 @@ class Gitlab::Client
|
|
|
77
77
|
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/take_ownership")
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
+
# Run a scheduled pipeline immediately.
|
|
81
|
+
#
|
|
82
|
+
# @example
|
|
83
|
+
# Gitlab.run_pipeline_schedule(5, 1)
|
|
84
|
+
#
|
|
85
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
86
|
+
# @param [Integer] trigger_id The pipeline schedule ID.
|
|
87
|
+
# @return [Gitlab::ObjectifiedHash] Pipeline created message.
|
|
88
|
+
def run_pipeline_schedule(project, pipeline_schedule_id)
|
|
89
|
+
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/play")
|
|
90
|
+
end
|
|
91
|
+
|
|
80
92
|
# Delete a pipeline schedule.
|
|
81
93
|
#
|
|
82
94
|
# @example
|
|
@@ -101,7 +113,7 @@ class Gitlab::Client
|
|
|
101
113
|
# @option options [String] :value The value of a variable
|
|
102
114
|
# @return [Array<Gitlab::ObjectifiedHash>] The created pipeline schedule variable.
|
|
103
115
|
def create_pipeline_schedule_variable(project, pipeline_schedule_id, options = {})
|
|
104
|
-
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables",
|
|
116
|
+
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables", body: options)
|
|
105
117
|
end
|
|
106
118
|
|
|
107
119
|
# Updates the variable of a pipeline schedule.
|
|
@@ -116,7 +128,7 @@ class Gitlab::Client
|
|
|
116
128
|
# @option options [String] :value The value of a variable.
|
|
117
129
|
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule variable.
|
|
118
130
|
def edit_pipeline_schedule_variable(project, pipeline_schedule_id, key, options = {})
|
|
119
|
-
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}",
|
|
131
|
+
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}", body: options)
|
|
120
132
|
end
|
|
121
133
|
|
|
122
134
|
# Delete the variable of a pipeline schedule
|
|
@@ -31,6 +31,30 @@ class Gitlab::Client
|
|
|
31
31
|
get("/projects/#{url_encode project}/pipelines/#{id}")
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
# Gets a single pipeline's test report.
|
|
35
|
+
#
|
|
36
|
+
# @example
|
|
37
|
+
# Gitlab.pipeline_test_report(5, 36)
|
|
38
|
+
#
|
|
39
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
40
|
+
# @param [Integer] id The ID of a pipeline.
|
|
41
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
42
|
+
def pipeline_test_report(project, id)
|
|
43
|
+
get("/projects/#{url_encode project}/pipelines/#{id}/test_report")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Gets a single pipeline's variables.
|
|
47
|
+
#
|
|
48
|
+
# @example
|
|
49
|
+
# Gitlab.pipeline_variables(5, 36)
|
|
50
|
+
#
|
|
51
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
52
|
+
# @param [Integer] id The ID of a pipeline.
|
|
53
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
54
|
+
def pipeline_variables(project, id)
|
|
55
|
+
get("/projects/#{url_encode project}/pipelines/#{id}/variables")
|
|
56
|
+
end
|
|
57
|
+
|
|
34
58
|
# Create a pipeline.
|
|
35
59
|
#
|
|
36
60
|
# @example
|
|
@@ -89,5 +113,18 @@ class Gitlab::Client
|
|
|
89
113
|
def delete_pipeline(project, id)
|
|
90
114
|
delete("/projects/#{url_encode project}/pipelines/#{id}")
|
|
91
115
|
end
|
|
116
|
+
|
|
117
|
+
# Update a pipeline metadata
|
|
118
|
+
#
|
|
119
|
+
# @example
|
|
120
|
+
# Gitlab.update_pipeline_metadata(5, 1, name: 'new name')
|
|
121
|
+
#
|
|
122
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
123
|
+
# @param [Integer] id The ID of a pipeline.
|
|
124
|
+
# @option options [String] :name The new name of the pipeline.
|
|
125
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
126
|
+
def update_pipeline_metadata(project, id, options = {})
|
|
127
|
+
put("/projects/#{url_encode project}/pipelines/#{id}/metadata", body: options)
|
|
128
|
+
end
|
|
92
129
|
end
|
|
93
130
|
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Gitlab::Client
|
|
4
|
+
# Defines methods related to project exports.
|
|
5
|
+
# @see https://docs.gitlab.com/ce/api/project_import_export.html
|
|
6
|
+
module ProjectExports
|
|
7
|
+
# Start a new export
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# Gitlab.export_project(2)
|
|
11
|
+
#
|
|
12
|
+
# @param [Integer, String] id The ID or path of a project.
|
|
13
|
+
# @param [Hash] options A customizable set of options.
|
|
14
|
+
# @option options [String] description(optional) Overrides the project description
|
|
15
|
+
# @option options [hash] upload(optional) Hash that contains the information to upload the exported project to a web server
|
|
16
|
+
# @option options [String] upload[url] TThe URL to upload the project
|
|
17
|
+
# @option options [String] upload[http_method](optional) The HTTP method to upload the exported project. Only PUT and POST methods allowed. Default is PUT
|
|
18
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
19
|
+
def export_project(id, options = {})
|
|
20
|
+
post("/projects/#{url_encode id}/export", body: options)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Get the status of export
|
|
24
|
+
#
|
|
25
|
+
# @example
|
|
26
|
+
# Gitlab.export_project_status(2)
|
|
27
|
+
#
|
|
28
|
+
# @param [Integer, String] id The ID or path of a project.
|
|
29
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
30
|
+
def export_project_status(id)
|
|
31
|
+
get("/projects/#{url_encode id}/export")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Download the finished export
|
|
35
|
+
#
|
|
36
|
+
# @example
|
|
37
|
+
# Gitlab.exported_project_download(2)
|
|
38
|
+
#
|
|
39
|
+
# @param [Integer, String] id The ID or path of a project.
|
|
40
|
+
# @return [Gitlab::FileResponse]
|
|
41
|
+
def exported_project_download(id)
|
|
42
|
+
get("/projects/#{url_encode id}/export/download",
|
|
43
|
+
format: nil,
|
|
44
|
+
headers: { Accept: 'application/octet-stream' },
|
|
45
|
+
parser: proc { |body, _|
|
|
46
|
+
if body.encoding == Encoding::ASCII_8BIT # binary response
|
|
47
|
+
::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
|
|
48
|
+
else # error with json response
|
|
49
|
+
::Gitlab::Request.parse(body)
|
|
50
|
+
end
|
|
51
|
+
})
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|