gitlab 4.16.1 → 4.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/gitlab/api.rb +2 -0
- data/lib/gitlab/cli.rb +4 -4
- data/lib/gitlab/cli_helpers.rb +2 -2
- data/lib/gitlab/client.rb +3 -1
- data/lib/gitlab/client/commits.rb +24 -3
- data/lib/gitlab/client/container_registry.rb +1 -1
- data/lib/gitlab/client/group_badges.rb +88 -0
- data/lib/gitlab/client/group_labels.rb +1 -1
- data/lib/gitlab/client/groups.rb +15 -0
- data/lib/gitlab/client/jobs.rb +77 -8
- data/lib/gitlab/client/labels.rb +1 -1
- data/lib/gitlab/client/pipeline_schedules.rb +4 -4
- data/lib/gitlab/client/pipelines.rb +12 -0
- data/lib/gitlab/client/projects.rb +35 -0
- data/lib/gitlab/client/resource_state_events.rb +57 -0
- data/lib/gitlab/client/runners.rb +59 -21
- data/lib/gitlab/error.rb +11 -0
- data/lib/gitlab/help.rb +2 -2
- data/lib/gitlab/paginated_response.rb +3 -3
- data/lib/gitlab/request.rb +0 -2
- data/lib/gitlab/shell_history.rb +2 -2
- data/lib/gitlab/version.rb +1 -1
- metadata +7 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3265eea0b2b8d118d2a8dc9e135a1e5eac505072d2291afeab157902c4d7d50c
|
4
|
+
data.tar.gz: a99c3230eb2d20f4c6f8ff198351944698a7a554632b5252646962371cc6885c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c115e9436d6214665e17c66e74e80730180bfb92e41b33dbc63c91c7de4d80883e7b0f0c8e27d806ac55c816640463219f12ff53ed4278cce7141b0e5ec72399
|
7
|
+
data.tar.gz: 3297df4d90a5de774d532c8ebf349a9b60907c110810bb4a258ae326376cbb4810231dbc1203e3743ddf9e81b97d869bed1952f59235c1d8ccf01bb9c3ea8be1
|
data/README.md
CHANGED
data/lib/gitlab/api.rb
CHANGED
@@ -10,6 +10,7 @@ module Gitlab
|
|
10
10
|
|
11
11
|
# Creates a new API.
|
12
12
|
# @raise [Error:MissingCredentials]
|
13
|
+
# rubocop:disable Lint/MissingSuper
|
13
14
|
def initialize(options = {})
|
14
15
|
options = Gitlab.options.merge(options)
|
15
16
|
(Configuration::VALID_OPTIONS_KEYS + [:auth_token]).each do |key|
|
@@ -18,5 +19,6 @@ module Gitlab
|
|
18
19
|
request_defaults(sudo)
|
19
20
|
self.class.headers 'User-Agent' => user_agent
|
20
21
|
end
|
22
|
+
# rubocop:enable Lint/MissingSuper
|
21
23
|
end
|
22
24
|
end
|
data/lib/gitlab/cli.rb
CHANGED
@@ -17,10 +17,10 @@ class Gitlab::CLI
|
|
17
17
|
# @param [Array] args The command and it's optional arguments.
|
18
18
|
def self.start(args)
|
19
19
|
command = begin
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
args.shift.strip
|
21
|
+
rescue StandardError
|
22
|
+
'help'
|
23
|
+
end
|
24
24
|
run(command, args)
|
25
25
|
end
|
26
26
|
|
data/lib/gitlab/cli_helpers.rb
CHANGED
@@ -111,7 +111,7 @@ class Gitlab::CLI
|
|
111
111
|
else
|
112
112
|
hash_result = case data
|
113
113
|
when Gitlab::ObjectifiedHash, Gitlab::FileResponse
|
114
|
-
record_hash([data], cmd, args, true)
|
114
|
+
record_hash([data], cmd, args, single_value: true)
|
115
115
|
when Gitlab::PaginatedResponse
|
116
116
|
record_hash(data, cmd, args)
|
117
117
|
else
|
@@ -162,7 +162,7 @@ class Gitlab::CLI
|
|
162
162
|
# @param [Array] args Options passed to the API call
|
163
163
|
# @param [bool] single_value If set to true, a single result should be returned
|
164
164
|
# @return [Hash] Result hash
|
165
|
-
def record_hash(data, cmd, args, single_value
|
165
|
+
def record_hash(data, cmd, args, single_value: false)
|
166
166
|
if data.empty?
|
167
167
|
result = nil
|
168
168
|
else
|
data/lib/gitlab/client.rb
CHANGED
@@ -23,6 +23,7 @@ module Gitlab
|
|
23
23
|
include Epics
|
24
24
|
include Events
|
25
25
|
include Features
|
26
|
+
include GroupBadges
|
26
27
|
include GroupBoards
|
27
28
|
include GroupLabels
|
28
29
|
include GroupMilestones
|
@@ -52,6 +53,7 @@ module Gitlab
|
|
52
53
|
include RepositoryFiles
|
53
54
|
include RepositorySubmodules
|
54
55
|
include ResourceLabelEvents
|
56
|
+
include ResourceStateEvents
|
55
57
|
include Runners
|
56
58
|
include Search
|
57
59
|
include Services
|
@@ -80,7 +82,7 @@ module Gitlab
|
|
80
82
|
#
|
81
83
|
# @return [String]
|
82
84
|
def url_encode(url)
|
83
|
-
url.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf('%%%02X', m.unpack1('C')) } # rubocop:disable Style/FormatString
|
85
|
+
url.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf('%%%02X', m.unpack1('C')) } # rubocop:disable Style/FormatString
|
84
86
|
end
|
85
87
|
|
86
88
|
private
|
@@ -59,9 +59,30 @@ class Gitlab::Client
|
|
59
59
|
# @param [Integer, String] project The ID or name of a project.
|
60
60
|
# @param [String] sha The commit hash or name of a repository branch or tag
|
61
61
|
# @param [String] branch The name of the branch
|
62
|
+
# @param [Hash] options A customizable set of options.
|
63
|
+
# @option options [Boolean] :dry_run Don't commit any changes
|
62
64
|
# @return [Gitlab::ObjectifiedHash]
|
63
|
-
def cherry_pick_commit(project, sha, branch)
|
64
|
-
|
65
|
+
def cherry_pick_commit(project, sha, branch, options = {})
|
66
|
+
options[:branch] = branch
|
67
|
+
|
68
|
+
post("/projects/#{url_encode project}/repository/commits/#{sha}/cherry_pick", body: options)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Reverts a commit in a given branch.
|
72
|
+
#
|
73
|
+
# @example
|
74
|
+
# Gitlab.revert_commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'master')
|
75
|
+
#
|
76
|
+
# @param [Integer, String] project The ID or name of a project.
|
77
|
+
# @param [String] sha The commit hash or name of a repository branch or tag
|
78
|
+
# @param [String] branch The name of the branch
|
79
|
+
# @param [Hash] options A customizable set of options.
|
80
|
+
# @option options [Boolean] :dry_run Don't commit any changes
|
81
|
+
# @return [Gitlab::ObjectifiedHash]
|
82
|
+
def revert_commit(project, sha, branch, options = {})
|
83
|
+
options[:branch] = branch
|
84
|
+
|
85
|
+
post("/projects/#{url_encode project}/repository/commits/#{sha}/revert", body: options)
|
65
86
|
end
|
66
87
|
|
67
88
|
# Get the diff of a commit in a project.
|
@@ -145,7 +166,7 @@ class Gitlab::Client
|
|
145
166
|
# @option options [String] :name Filter by status name, eg. jenkins
|
146
167
|
# @option options [String] :target_url The target URL to associate with this status
|
147
168
|
def update_commit_status(project, sha, state, options = {})
|
148
|
-
post("/projects/#{url_encode project}/statuses/#{sha}",
|
169
|
+
post("/projects/#{url_encode project}/statuses/#{sha}", body: options.merge(state: state))
|
149
170
|
end
|
150
171
|
alias repo_update_commit_status update_commit_status
|
151
172
|
|
@@ -79,7 +79,7 @@ class Gitlab::Client
|
|
79
79
|
# @option options [String] :older_than(required) Tags to delete that are older than the given time, written in human readable form 1h, 1d, 1month.
|
80
80
|
# @return [void] This API call returns an empty response body.
|
81
81
|
def bulk_delete_registry_repository_tags(project, repository_id, options = {})
|
82
|
-
delete("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags",
|
82
|
+
delete("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags", body: options)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to group badges.
|
5
|
+
# @see https://docs.gitlab.com/ee/api/group_badges.html
|
6
|
+
module GroupBadges
|
7
|
+
# Gets a list of a groups badges.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.group_badges(5)
|
11
|
+
# Gitlab.group_badges(5, 'Coverage')
|
12
|
+
#
|
13
|
+
# @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
|
14
|
+
# @param [String] name(optional) Name of the badges to return (case-sensitive).
|
15
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of all badges of a group
|
16
|
+
def group_badges(group, name = nil)
|
17
|
+
query = { name: name } if name
|
18
|
+
get("/groups/#{url_encode group}/badges", query: query)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Gets a badge of a group.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# Gitlab.group_badge(5, 42)
|
25
|
+
#
|
26
|
+
# @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
|
27
|
+
# @param [Integer] badge_id(required) The badge ID.
|
28
|
+
# @return [Gitlab::ObjectifiedHash] Information about the requested badge
|
29
|
+
def group_badge(group, badge_id)
|
30
|
+
get("/groups/#{url_encode group}/badges/#{badge_id}")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Adds a badge to a group.
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# Gitlab.add_group_badge(5, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })
|
37
|
+
#
|
38
|
+
# @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
|
39
|
+
# @param [Hash] options A customizable set of options.
|
40
|
+
# @option options [String] :link_url(required) URL of the badge link
|
41
|
+
# @option options [String] :image_url(required) URL of the badge image
|
42
|
+
# @return [Gitlab::ObjectifiedHash] Information about the added group badge.
|
43
|
+
def add_group_badge(group, options = {})
|
44
|
+
post("/groups/#{url_encode group}/badges", body: options)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Updates a badge of a group.
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# Gitlab.edit_group_badge(5, 1, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })
|
51
|
+
#
|
52
|
+
# @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
|
53
|
+
# @param [Integer] badge_id(required) The badge ID.
|
54
|
+
# @param [Hash] options A customizable set of options.
|
55
|
+
# @option options [String] :link_url(optional) URL of the badge link
|
56
|
+
# @option options [String] :image_url(optional) URL of the badge image
|
57
|
+
# @return [Gitlab::ObjectifiedHash] Information about the updated group badge.
|
58
|
+
def edit_group_badge(group, badge_id, options = {})
|
59
|
+
put("/groups/#{url_encode group}/badges/#{badge_id}", body: options)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Removes a badge from a group.
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
# Gitlab.remove_group_badge(5, 42)
|
66
|
+
#
|
67
|
+
# @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
|
68
|
+
# @param [Integer] badge_id(required) The badge ID.
|
69
|
+
# @return [nil] This API call returns an empty response body.
|
70
|
+
def remove_group_badge(group, badge_id)
|
71
|
+
delete("/groups/#{url_encode group}/badges/#{badge_id}")
|
72
|
+
end
|
73
|
+
|
74
|
+
# Preview a badge from a group.
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# Gitlab.preview_group_badge(3, 'https://abc.com/gitlab/gitlab-ce/commits/master', 'https://shields.io/my/badge1')
|
78
|
+
#
|
79
|
+
# @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
|
80
|
+
# @param [String] :link_url(required) URL of the badge link
|
81
|
+
# @param [String] :image_url(required) URL of the badge image
|
82
|
+
# @return [Gitlab::ObjectifiedHash] Returns how the link_url and image_url final URLs would be after resolving the placeholder interpolation.
|
83
|
+
def preview_group_badge(group, link_url, image_url)
|
84
|
+
query = { link_url: link_url, image_url: image_url }
|
85
|
+
get("/groups/#{url_encode group}/badges/render", query: query)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -58,7 +58,7 @@ class Gitlab::Client
|
|
58
58
|
# @param [String] name The name of a label.
|
59
59
|
# @return [Gitlab::ObjectifiedHash] Information about deleted label.
|
60
60
|
def delete_group_label(group, name)
|
61
|
-
delete("/groups/#{url_encode group}/labels
|
61
|
+
delete("/groups/#{url_encode group}/labels/#{name}")
|
62
62
|
end
|
63
63
|
|
64
64
|
# Subscribes the user to a group label to receive notifications
|
data/lib/gitlab/client/groups.rb
CHANGED
@@ -71,6 +71,21 @@ class Gitlab::Client
|
|
71
71
|
get("/groups/#{url_encode id}/members", query: options)
|
72
72
|
end
|
73
73
|
|
74
|
+
# Get a list of group members that are billable.
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# Gitlab.group_billable_members(1)
|
78
|
+
# Gitlab.group_billable_members(1, { per_page: 40 })
|
79
|
+
#
|
80
|
+
# @param [Integer] id The ID of a group.
|
81
|
+
# @param [Hash] options A customizable set of options.
|
82
|
+
# @option options [Integer] :page The page number.
|
83
|
+
# @option options [Integer] :per_page The number of results per page.
|
84
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
85
|
+
def group_billable_members(id, options = {})
|
86
|
+
get("/groups/#{url_encode id}/billable_members", query: options)
|
87
|
+
end
|
88
|
+
|
74
89
|
# Get details of a single group member.
|
75
90
|
#
|
76
91
|
# @example
|
data/lib/gitlab/client/jobs.rb
CHANGED
@@ -36,6 +36,21 @@ class Gitlab::Client
|
|
36
36
|
get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/jobs", query: options)
|
37
37
|
end
|
38
38
|
|
39
|
+
# Gets a list of Bridge Jobs from a pipeline
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# Gitlab.pipeline_bridges(1, 2)
|
43
|
+
# Gitlab.pipeline_bridges("project", 2)
|
44
|
+
#
|
45
|
+
# @param [Integer, String] The ID or name of a project.
|
46
|
+
# @param [Integer] the id of the pipeline
|
47
|
+
# @param [Hash] options A customizable set of options.
|
48
|
+
# @option options [Array] :scope The scope of bridge jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all bridge jobs if none provided.
|
49
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
50
|
+
def pipeline_bridges(project_id, pipeline_id, options = {})
|
51
|
+
get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/bridges", query: options)
|
52
|
+
end
|
53
|
+
|
39
54
|
# Gets a single job
|
40
55
|
#
|
41
56
|
# @example
|
@@ -70,16 +85,70 @@ class Gitlab::Client
|
|
70
85
|
# Gitlab.job_artifacts_download(1, "master", "release")
|
71
86
|
# Gitlab.job_artifacts_download("project", "master", "release")
|
72
87
|
#
|
73
|
-
# @param [Integer, String]
|
74
|
-
# @param [String] ref
|
75
|
-
# @param [String] job
|
76
|
-
# @return [
|
88
|
+
# @param [Integer, String] project_id The ID or name of a project.
|
89
|
+
# @param [String] ref Ref Name
|
90
|
+
# @param [String] job jobname
|
91
|
+
# @return [Gitlab::FileResponse]
|
77
92
|
def job_artifacts_download(project_id, ref_name, job_name)
|
78
|
-
get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download",
|
79
|
-
|
80
|
-
|
81
|
-
|
93
|
+
get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download",
|
94
|
+
query: { job: job_name },
|
95
|
+
format: nil,
|
96
|
+
headers: { Accept: 'application/octet-stream' },
|
97
|
+
parser: proc { |body, _|
|
98
|
+
if body.encoding == Encoding::ASCII_8BIT # binary response
|
99
|
+
::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
|
100
|
+
else # error with json response
|
101
|
+
::Gitlab::Request.parse(body)
|
102
|
+
end
|
103
|
+
})
|
104
|
+
end
|
105
|
+
|
106
|
+
# Download a single artifact file by job ID
|
107
|
+
#
|
108
|
+
# @example
|
109
|
+
# Gitlab.download_job_artifact_file(1, 5, "some/release/file.pdf")
|
110
|
+
#
|
111
|
+
# @param [Integer, String] project_id(required) The ID or name of a project.
|
112
|
+
# @param [String] job_id(required) The unique job identifier.
|
113
|
+
# @param [String] artifact_path(required) Path to a file inside the artifacts archive.
|
114
|
+
# @return [Gitlab::FileResponse]
|
115
|
+
def download_job_artifact_file(project_id, job_id, artifact_path)
|
116
|
+
get("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/#{artifact_path}",
|
117
|
+
format: nil,
|
118
|
+
headers: { Accept: 'application/octet-stream' },
|
119
|
+
parser: proc { |body, _|
|
120
|
+
if body.encoding == Encoding::ASCII_8BIT # binary response
|
121
|
+
::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
|
122
|
+
else # error with json response
|
123
|
+
::Gitlab::Request.parse(body)
|
124
|
+
end
|
125
|
+
})
|
126
|
+
end
|
127
|
+
|
128
|
+
# Download a single artifact file from specific tag or branch
|
129
|
+
#
|
130
|
+
# @example
|
131
|
+
# Gitlab.download_branch_artifact_file(1, "master", "some/release/file.pdf", 'pdf')
|
132
|
+
#
|
133
|
+
# @param [Integer, String] project_id(required) The ID or name of a project.
|
134
|
+
# @param [String] ref_name(required) Branch or tag name in repository. HEAD or SHA references are not supported.
|
135
|
+
# @param [String] artifact_path(required) Path to a file inside the artifacts archive.
|
136
|
+
# @param [String] job(required) The name of the job.
|
137
|
+
# @return [Gitlab::FileResponse]
|
138
|
+
def download_branch_artifact_file(project_id, ref_name, artifact_path, job)
|
139
|
+
get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/raw/#{artifact_path}",
|
140
|
+
query: { job: job },
|
141
|
+
format: nil,
|
142
|
+
headers: { Accept: 'application/octet-stream' },
|
143
|
+
parser: proc { |body, _|
|
144
|
+
if body.encoding == Encoding::ASCII_8BIT # binary response
|
145
|
+
::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
|
146
|
+
else # error with json response
|
147
|
+
::Gitlab::Request.parse(body)
|
148
|
+
end
|
149
|
+
})
|
82
150
|
end
|
151
|
+
alias download_tag_artifact_file download_branch_artifact_file
|
83
152
|
|
84
153
|
# Get Job Trace
|
85
154
|
#
|
data/lib/gitlab/client/labels.rb
CHANGED
@@ -58,7 +58,7 @@ class Gitlab::Client
|
|
58
58
|
# @param [String] name The name of a label.
|
59
59
|
# @return [Gitlab::ObjectifiedHash] Information about deleted label.
|
60
60
|
def delete_label(project, name)
|
61
|
-
delete("/projects/#{url_encode project}/labels
|
61
|
+
delete("/projects/#{url_encode project}/labels/#{name}")
|
62
62
|
end
|
63
63
|
|
64
64
|
# Subscribes the user to a label to receive notifications
|
@@ -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.
|
@@ -101,7 +101,7 @@ class Gitlab::Client
|
|
101
101
|
# @option options [String] :value The value of a variable
|
102
102
|
# @return [Array<Gitlab::ObjectifiedHash>] The created pipeline schedule variable.
|
103
103
|
def create_pipeline_schedule_variable(project, pipeline_schedule_id, options = {})
|
104
|
-
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables",
|
104
|
+
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables", body: options)
|
105
105
|
end
|
106
106
|
|
107
107
|
# Updates the variable of a pipeline schedule.
|
@@ -116,7 +116,7 @@ class Gitlab::Client
|
|
116
116
|
# @option options [String] :value The value of a variable.
|
117
117
|
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule variable.
|
118
118
|
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}",
|
119
|
+
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}", body: options)
|
120
120
|
end
|
121
121
|
|
122
122
|
# Delete the variable of a pipeline schedule
|
@@ -31,6 +31,18 @@ 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
|
+
|
34
46
|
# Create a pipeline.
|
35
47
|
#
|
36
48
|
# @example
|
@@ -102,6 +102,22 @@ class Gitlab::Client
|
|
102
102
|
get("/projects/#{url_encode project}/members", query: options)
|
103
103
|
end
|
104
104
|
|
105
|
+
# Gets a list of all project team members including inherited members.
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
# Gitlab.all_members(42)
|
109
|
+
# Gitlab.all_members('gitlab')
|
110
|
+
#
|
111
|
+
# @param [Integer, String] project The ID or path of a project.
|
112
|
+
# @param [Hash] options A customizable set of options.
|
113
|
+
# @option options [String] :query The search query.
|
114
|
+
# @option options [Integer] :page The page number.
|
115
|
+
# @option options [Integer] :per_page The number of results per page.
|
116
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
117
|
+
def all_members(project, options = {})
|
118
|
+
get("/projects/#{url_encode project}/members/all", query: options)
|
119
|
+
end
|
120
|
+
|
105
121
|
# Gets a project team member.
|
106
122
|
#
|
107
123
|
# @example
|
@@ -519,6 +535,25 @@ class Gitlab::Client
|
|
519
535
|
delete("/projects/#{url_encode id}/star")
|
520
536
|
end
|
521
537
|
|
538
|
+
# Get a list of visible projects that the given user has starred.
|
539
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#list-projects-starred-by-a-user
|
540
|
+
#
|
541
|
+
# @example
|
542
|
+
# Gitlab.user_starred_projects(1)
|
543
|
+
# Gitlab.user_starred_projects(1, { order_by: 'last_activity_at' })
|
544
|
+
# Gitlab.user_starred_projects('username', { order_by: 'name', sort: 'asc' })
|
545
|
+
#
|
546
|
+
# @param [Integer, String] user_id The ID or username of the user.
|
547
|
+
# @param [Hash] options A customizable set of options.
|
548
|
+
# @option options [String] :per_page Number of projects to return per page
|
549
|
+
# @option options [String] :page The page to retrieve
|
550
|
+
# @option options [String] :order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
|
551
|
+
# @option options [String] :sort Return projects sorted in asc or desc order.
|
552
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
553
|
+
def user_starred_projects(user_id, options = {})
|
554
|
+
get("/users/#{url_encode user_id}/starred_projects", query: options)
|
555
|
+
end
|
556
|
+
|
522
557
|
# Get a list of visible projects for the given user.
|
523
558
|
# @see https://docs.gitlab.com/ee/api/projects.html#list-user-projects
|
524
559
|
#
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to resource state events.
|
5
|
+
# @see https://docs.gitlab.com/ee/api/resource_state_events.html
|
6
|
+
module ResourceStateEvents
|
7
|
+
# Gets a list of all state events for a single issue.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.issue_state_events(5, 42)
|
11
|
+
#
|
12
|
+
# @param [Integer, String] project The ID or name of a project.
|
13
|
+
# @param [Integer] issue_iid The IID of an issue.
|
14
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
15
|
+
def issue_state_events(project, issue_iid)
|
16
|
+
get("/projects/#{url_encode project}/issues/#{issue_iid}/resource_state_events")
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns a single state event for a specific project issue
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# Gitlab.issue_state_event(5, 42, 1)
|
23
|
+
#
|
24
|
+
# @param [Integer, String] project The ID or name of a project.
|
25
|
+
# @param [Integer] issue_iid The IID of an issue.
|
26
|
+
# @param [Integer] id The ID of a resource event.
|
27
|
+
# @return Gitlab::ObjectifiedHash
|
28
|
+
def issue_state_event(project, issue_iid, id)
|
29
|
+
get("/projects/#{url_encode project}/issues/#{issue_iid}/resource_state_events/#{id}")
|
30
|
+
end
|
31
|
+
|
32
|
+
# Gets a list of all state events for a single merge request.
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# Gitlab.merge_request_state_events(5, 42)
|
36
|
+
#
|
37
|
+
# @param [Integer, String] project The ID or name of a project.
|
38
|
+
# @param [Integer] merge_request_iid The IID of a merge request.
|
39
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
40
|
+
def merge_request_state_events(project, merge_request_iid)
|
41
|
+
get("/projects/#{url_encode project}/merge_requests/#{merge_request_iid}/resource_state_events")
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns a single state event for a specific project merge request
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
# Gitlab.merge_request_state_event(5, 42, 1)
|
48
|
+
#
|
49
|
+
# @param [Integer, String] project The ID or name of a project.
|
50
|
+
# @param [Integer] merge_request_iid The IID of an merge request.
|
51
|
+
# @param [Integer] id The ID of a state event.
|
52
|
+
# @return Gitlab::ObjectifiedHash
|
53
|
+
def merge_request_state_event(project, merge_request_iid, id)
|
54
|
+
get("/projects/#{url_encode project}/merge_requests/#{merge_request_iid}/resource_state_events/#{id}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -9,11 +9,13 @@ class Gitlab::Client
|
|
9
9
|
#
|
10
10
|
# @example
|
11
11
|
# Gitlab.runners
|
12
|
-
# Gitlab.runners(:active)
|
13
|
-
# Gitlab.runners(:
|
12
|
+
# Gitlab.runners(type: 'instance_type', status: 'active')
|
13
|
+
# Gitlab.runners(tag_list: 'tag1,tag2')
|
14
14
|
#
|
15
15
|
# @param [Hash] options A customizable set of options.
|
16
|
-
# @option options [String] :
|
16
|
+
# @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
|
17
|
+
# @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
|
18
|
+
# @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
|
17
19
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
18
20
|
def runners(options = {})
|
19
21
|
get('/runners', query: options)
|
@@ -24,9 +26,13 @@ class Gitlab::Client
|
|
24
26
|
#
|
25
27
|
# @example
|
26
28
|
# Gitlab.all_runners
|
29
|
+
# Gitlab.all_runners(type: 'instance_type', status: 'active')
|
30
|
+
# Gitlab.all_runners(tag_list: 'tag1,tag2')
|
27
31
|
#
|
28
32
|
# @param [Hash] options A customizable set of options.
|
29
|
-
# @option options [String] :
|
33
|
+
# @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
|
34
|
+
# @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
|
35
|
+
# @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
|
30
36
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
31
37
|
def all_runners(options = {})
|
32
38
|
get('/runners/all', query: options)
|
@@ -50,15 +56,19 @@ class Gitlab::Client
|
|
50
56
|
# @example
|
51
57
|
# Gitlab.update_runner(42, { description: 'Awesome runner' })
|
52
58
|
# Gitlab.update_runner(42, { active: false })
|
53
|
-
# Gitlab.update_runner(42, { tag_list: [ 'awesome', 'runner' ] })
|
54
59
|
#
|
55
60
|
# @param [Integer, String] id The ID of a runner
|
56
61
|
# @param [Hash] options A customizable set of options.
|
57
|
-
# @option options [String] :
|
58
|
-
# @option options [
|
62
|
+
# @option options [String] :description(optional) The description of a runner
|
63
|
+
# @option options [Boolean] :active(optional) The state of a runner; can be set to true or false
|
64
|
+
# @option options [String] :tag_list(optional) The list of tags for a runner; put array of tags, that should be finally assigned to a runner(separated by comma)
|
65
|
+
# @option options [Boolean] :run_untagged(optional) Flag indicating the runner can execute untagged jobs
|
66
|
+
# @option options [Boolean] :locked(optional) Flag indicating the runner is locked
|
67
|
+
# @option options [String] :access_level(optional) The access_level of the runner; not_protected or ref_protected
|
68
|
+
# @option options [Integer] :maximum_timeout(optional) Maximum timeout set when this runner will handle the job
|
59
69
|
# @return <Gitlab::ObjectifiedHash>
|
60
70
|
def update_runner(id, options = {})
|
61
|
-
put("/runners/#{id}",
|
71
|
+
put("/runners/#{id}", body: options)
|
62
72
|
end
|
63
73
|
|
64
74
|
# Remove a runner.
|
@@ -68,19 +78,23 @@ class Gitlab::Client
|
|
68
78
|
# Gitlab.delete_runner(42)
|
69
79
|
#
|
70
80
|
# @param [Integer, String] id The ID of a runner
|
71
|
-
# @return
|
81
|
+
# @return [nil] This API call returns an empty response body.
|
72
82
|
def delete_runner(id)
|
73
83
|
delete("/runners/#{id}")
|
74
84
|
end
|
75
85
|
|
76
|
-
#
|
86
|
+
# List jobs that are being processed or were processed by specified runner.
|
77
87
|
#
|
78
88
|
# @example
|
79
89
|
# Gitlab.runner_jobs(1)
|
90
|
+
# Gitlab.runner_jobs(1, status: 'success')
|
91
|
+
# Gitlab.runner_jobs(1, sort: 'desc')
|
80
92
|
#
|
81
93
|
# @param [Integer] id The ID of a runner.
|
82
94
|
# @param [Hash] options A customizable set of options.
|
83
|
-
# @option options [String] :status Status of the job; one of: running, success, failed, canceled
|
95
|
+
# @option options [String] :status(optional) Status of the job; one of: running, success, failed, canceled
|
96
|
+
# @option options [String] :order_by(optional) Order jobs by id.
|
97
|
+
# @option options [String] :sort(optional) Sort jobs in asc or desc order (default: desc)
|
84
98
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
85
99
|
def runner_jobs(runner_id, options = {})
|
86
100
|
get("/runners/#{url_encode runner_id}/jobs", query: options)
|
@@ -91,11 +105,17 @@ class Gitlab::Client
|
|
91
105
|
#
|
92
106
|
# @example
|
93
107
|
# Gitlab.project_runners(42)
|
108
|
+
# Gitlab.project_runners(42, type: 'instance_type', status: 'active')
|
109
|
+
# Gitlab.project_runners(42, tag_list: 'tag1,tag2')
|
94
110
|
#
|
95
111
|
# @param [Integer, String] id The ID or name of a project.
|
112
|
+
# @param [Hash] options A customizable set of options.
|
113
|
+
# @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
|
114
|
+
# @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
|
115
|
+
# @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
|
96
116
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
97
|
-
def project_runners(project_id)
|
98
|
-
get("/projects/#{url_encode project_id}/runners")
|
117
|
+
def project_runners(project_id, options = {})
|
118
|
+
get("/projects/#{url_encode project_id}/runners", query: options)
|
99
119
|
end
|
100
120
|
|
101
121
|
# Enable an available specific runner in the project.
|
@@ -125,21 +145,39 @@ class Gitlab::Client
|
|
125
145
|
delete("/projects/#{url_encode id}/runners/#{runner_id}")
|
126
146
|
end
|
127
147
|
|
148
|
+
# List all runners (specific and shared) available in the group as well its ancestor groups. Shared runners are listed if at least one shared runner is defined.
|
149
|
+
# @see https://docs.gitlab.com/ee/api/runners.html#list-groups-runners
|
150
|
+
#
|
151
|
+
# @example
|
152
|
+
# Gitlab.group_runners(9)
|
153
|
+
# Gitlab.group_runners(9, type: 'instance_type', status: 'active')
|
154
|
+
# Gitlab.group_runners(9, tag_list: 'tag1,tag2')
|
155
|
+
#
|
156
|
+
# @param [Integer, String] id The ID or name of a project.
|
157
|
+
# @param [Hash] options A customizable set of options.
|
158
|
+
# @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
|
159
|
+
# @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
|
160
|
+
# @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
|
161
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
162
|
+
def group_runners(group, options = {})
|
163
|
+
get("/groups/#{url_encode group}/runners", query: options)
|
164
|
+
end
|
165
|
+
|
128
166
|
# Register a new Runner for the instance.
|
129
167
|
#
|
130
168
|
# @example
|
131
169
|
# Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e')
|
132
170
|
# Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e', description: 'Some Description', active: true, locked: false)
|
133
171
|
#
|
134
|
-
# @param [String] token Registration token.
|
172
|
+
# @param [String] token(required) Registration token.
|
135
173
|
# @param [Hash] options A customizable set of options.
|
136
|
-
# @option options [String] :description Runner description.
|
137
|
-
# @option options [Hash] :info Runner metadata.
|
138
|
-
# @option options [Boolean] :active Whether the Runner is active.
|
139
|
-
# @option options [Boolean] :locked Whether the Runner should be locked for current project.
|
140
|
-
# @option options [Boolean] :run_untagged Whether the Runner should handle untagged jobs.
|
141
|
-
# @option options [Array<String>] :tag_list List of Runner tags.
|
142
|
-
# @option options [Integer] :maximum_timeout Maximum timeout set when this Runner will handle the job.
|
174
|
+
# @option options [String] :description(optional) Runner description.
|
175
|
+
# @option options [Hash] :info(optional) Runner metadata.
|
176
|
+
# @option options [Boolean] :active(optional) Whether the Runner is active.
|
177
|
+
# @option options [Boolean] :locked(optional) Whether the Runner should be locked for current project.
|
178
|
+
# @option options [Boolean] :run_untagged(optional) Whether the Runner should handle untagged jobs.
|
179
|
+
# @option options [Array<String>] :tag_list(optional) List of Runner tags.
|
180
|
+
# @option options [Integer] :maximum_timeout(optional) Maximum timeout set when this Runner will handle the job.
|
143
181
|
# @return <Gitlab::ObjectifiedHash> Response against runner registration
|
144
182
|
def register_runner(token, options = {})
|
145
183
|
body = { token: token }.merge(options)
|
data/lib/gitlab/error.rb
CHANGED
@@ -34,6 +34,17 @@ module Gitlab
|
|
34
34
|
@response.parsed_response.message
|
35
35
|
end
|
36
36
|
|
37
|
+
# Additional error context returned by some API endpoints
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
def error_code
|
41
|
+
if @response.respond_to?(:error_code)
|
42
|
+
@response.error_code
|
43
|
+
else
|
44
|
+
''
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
37
48
|
private
|
38
49
|
|
39
50
|
# Human friendly message.
|
data/lib/gitlab/help.rb
CHANGED
@@ -74,14 +74,14 @@ module Gitlab::Help
|
|
74
74
|
# Returns full namespace of a command (e.g. Gitlab::Client::Branches.cmd)
|
75
75
|
def namespace(cmd)
|
76
76
|
method_owners.select { |method| method[:name] == cmd }
|
77
|
-
.map { |method| method[:owner]
|
77
|
+
.map { |method| "#{method[:owner]}.#{method[:name]}" }
|
78
78
|
.shift
|
79
79
|
end
|
80
80
|
|
81
81
|
# Massage output from 'ri'.
|
82
82
|
def change_help_output!(cmd, output_str)
|
83
83
|
output_str = +output_str
|
84
|
-
output_str.gsub!(/#{cmd}\((.*?)\)/m, cmd
|
84
|
+
output_str.gsub!(/#{cmd}\((.*?)\)/m, "#{cmd} \1")
|
85
85
|
output_str.gsub!(/,\s*/, ' ')
|
86
86
|
|
87
87
|
# Ensure @option descriptions are on a single line
|
@@ -43,17 +43,17 @@ module Gitlab
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def lazy_paginate
|
46
|
-
to_enum(:each_page).lazy.flat_map(&:to_ary)
|
46
|
+
to_enum(:each_page).lazy.flat_map(&:to_ary) # rubocop:disable Lint/ToEnumArguments
|
47
47
|
end
|
48
48
|
|
49
49
|
def auto_paginate(&block)
|
50
|
-
return lazy_paginate.to_a unless
|
50
|
+
return lazy_paginate.to_a unless block
|
51
51
|
|
52
52
|
lazy_paginate.each(&block)
|
53
53
|
end
|
54
54
|
|
55
55
|
def paginate_with_limit(limit, &block)
|
56
|
-
return lazy_paginate.take(limit).to_a unless
|
56
|
+
return lazy_paginate.take(limit).to_a unless block
|
57
57
|
|
58
58
|
lazy_paginate.take(limit).each(&block)
|
59
59
|
end
|
data/lib/gitlab/request.rb
CHANGED
data/lib/gitlab/shell_history.rb
CHANGED
@@ -42,10 +42,10 @@ class Gitlab::Shell
|
|
42
42
|
File.expand_path(@file_path)
|
43
43
|
end
|
44
44
|
|
45
|
-
def read_from_file
|
45
|
+
def read_from_file(&block)
|
46
46
|
path = history_file_path
|
47
47
|
|
48
|
-
File.foreach(path
|
48
|
+
File.foreach(path, &block) if File.exist?(path)
|
49
49
|
rescue StandardError => e
|
50
50
|
warn "History file not loaded: #{e.message}"
|
51
51
|
end
|
data/lib/gitlab/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nihad Abbasov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -17,20 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '0.
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.14.0
|
20
|
+
version: '0.18'
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
27
24
|
requirements:
|
28
25
|
- - "~>"
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version: '0.
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.14.0
|
27
|
+
version: '0.18'
|
34
28
|
- !ruby/object:Gem::Dependency
|
35
29
|
name: terminal-table
|
36
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,6 +122,7 @@ files:
|
|
128
122
|
- lib/gitlab/client/epics.rb
|
129
123
|
- lib/gitlab/client/events.rb
|
130
124
|
- lib/gitlab/client/features.rb
|
125
|
+
- lib/gitlab/client/group_badges.rb
|
131
126
|
- lib/gitlab/client/group_boards.rb
|
132
127
|
- lib/gitlab/client/group_labels.rb
|
133
128
|
- lib/gitlab/client/group_milestones.rb
|
@@ -157,6 +152,7 @@ files:
|
|
157
152
|
- lib/gitlab/client/repository_files.rb
|
158
153
|
- lib/gitlab/client/repository_submodules.rb
|
159
154
|
- lib/gitlab/client/resource_label_events.rb
|
155
|
+
- lib/gitlab/client/resource_state_events.rb
|
160
156
|
- lib/gitlab/client/runners.rb
|
161
157
|
- lib/gitlab/client/search.rb
|
162
158
|
- lib/gitlab/client/services.rb
|
@@ -200,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
196
|
- !ruby/object:Gem::Version
|
201
197
|
version: '0'
|
202
198
|
requirements: []
|
203
|
-
rubygems_version: 3.1.
|
199
|
+
rubygems_version: 3.1.4
|
204
200
|
signing_key:
|
205
201
|
specification_version: 4
|
206
202
|
summary: A Ruby wrapper and CLI for the GitLab API
|