gitlab 3.7.0 → 4.0.0
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 +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +2 -2
- data/CHANGELOG.md +24 -0
- data/README.md +7 -6
- data/gitlab.gemspec +4 -6
- data/lib/gitlab/client.rb +24 -0
- data/lib/gitlab/client/branches.rb +13 -13
- data/lib/gitlab/client/build_triggers.rb +9 -9
- data/lib/gitlab/client/build_variables.rb +11 -11
- data/lib/gitlab/client/builds.rb +16 -16
- data/lib/gitlab/client/commits.rb +39 -14
- data/lib/gitlab/client/groups.rb +1 -1
- data/lib/gitlab/client/issues.rb +40 -16
- data/lib/gitlab/client/labels.rb +9 -9
- data/lib/gitlab/client/merge_requests.rb +61 -24
- data/lib/gitlab/client/milestones.rb +25 -11
- data/lib/gitlab/client/namespaces.rb +2 -1
- data/lib/gitlab/client/notes.rb +16 -16
- data/lib/gitlab/client/pipelines.rb +68 -0
- data/lib/gitlab/client/projects.rb +111 -49
- data/lib/gitlab/client/repositories.rb +27 -23
- data/lib/gitlab/client/repository_files.rb +29 -10
- data/lib/gitlab/client/runners.rb +15 -15
- data/lib/gitlab/client/services.rb +8 -6
- data/lib/gitlab/client/snippets.rb +13 -13
- data/lib/gitlab/client/system_hooks.rb +1 -1
- data/lib/gitlab/client/tags.rb +13 -13
- data/lib/gitlab/client/users.rb +12 -5
- data/lib/gitlab/file_response.rb +1 -0
- data/lib/gitlab/version.rb +1 -1
- data/spec/fixtures/merge_request_closes_issues.json +1 -0
- data/spec/fixtures/milestone_merge_requests.json +1 -0
- data/spec/fixtures/pipeline.json +23 -0
- data/spec/fixtures/pipeline_cancel.json +23 -0
- data/spec/fixtures/pipeline_create.json +23 -0
- data/spec/fixtures/pipeline_retry.json +23 -0
- data/spec/fixtures/pipelines.json +48 -0
- data/spec/fixtures/project_commit_create.json +22 -0
- data/spec/fixtures/project_star.json +44 -0
- data/spec/fixtures/project_unstar.json +44 -0
- data/spec/fixtures/{git_hook.json → push_rule.json} +0 -0
- data/spec/gitlab/cli_spec.rb +9 -0
- data/spec/gitlab/client/client_spec.rb +11 -0
- data/spec/gitlab/client/commits_spec.rb +31 -0
- data/spec/gitlab/client/issues_spec.rb +48 -0
- data/spec/gitlab/client/merge_requests_spec.rb +57 -10
- data/spec/gitlab/client/milestones_spec.rb +16 -0
- data/spec/gitlab/client/pipelines_spec.rb +95 -0
- data/spec/gitlab/client/projects_spec.rb +116 -38
- data/spec/gitlab/client/repositories_spec.rb +0 -15
- data/spec/gitlab/client/repository_files_spec.rb +17 -2
- data/spec/gitlab/client/users_spec.rb +31 -13
- data/spec/gitlab/file_response_spec.rb +6 -1
- metadata +53 -43
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b76c82ead8e87ca095bc2ad47515701b11c9735f
|
4
|
+
data.tar.gz: 758f96760c958422f9642878247aad32cc5962be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 14dcda9a02593219e14e7dd67f4480790022c755a7e2261da430784464a2cfc6c0c0f68f8eb3a599f08a39f27bf69e8c9b271bfc54ad4ae71393b56493e88283
|
7
|
+
data.tar.gz: 2b0c3d034013eaffaf176de7a334c95efc15d4f979dfa9e83e4e70de881571925a6d7ec03571ba55076506580673e5bf9b2584e0e99e285f1b763ba7506008c2
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
## Change Log
|
2
2
|
|
3
|
+
### Unreleased
|
4
|
+
|
5
|
+
### 4.0.0 (10/04/2017)
|
6
|
+
- Adds ability to create commits in a repository - (@logicminds)
|
7
|
+
- Remove Ruby 1.x support from the project - (@orta)
|
8
|
+
- Add `star_project` and `unstar_project` methods. (@connorshea)
|
9
|
+
- Lock terminal-table to prevent build failures on Ruby 1.9/2.0. (@connorshea)
|
10
|
+
- Update documentation to link to docs.gitlab.com instead of the GitHub mirror for GitLab CE. (@connorshea)
|
11
|
+
- Add method `share_project_with_group` (@danhalligan)
|
12
|
+
- Allow to retrieve `ssh_keys` for a specific user(@dirker)
|
13
|
+
- Allow issues to use NAMESPACE/REPO identifier (@brodock)
|
14
|
+
- Add issues subscribe/unsubscribe (@newellista)
|
15
|
+
- Add merge_requests subscribe/unsubscribe (@newellista)
|
16
|
+
- Updated `deploy_key` endpoints (@epintozzi)
|
17
|
+
- Add milestone/merge_requests (API V4 only) (@joren)
|
18
|
+
- Rename "git hook" to "push rule". (@asedge)
|
19
|
+
- Change project fork endpoint for v4 API. (@asedge)
|
20
|
+
- Block/unblock user now uses POST instead of PUT. (@asedge)
|
21
|
+
- Project ID can also be a string (namespace/project_name). (@bergholdt)
|
22
|
+
- Support pipeline. (@bergholdt)
|
23
|
+
- Add methods to disable and enable deploy keys on projects. (@buzzdeee)
|
24
|
+
- Add method to fetch issues a merge request will close. (@joren)
|
25
|
+
- Fix `get_file` and `file_contents` methods to work with APIv4. (@asedge)
|
26
|
+
|
3
27
|
### 3.7.0 (16/08/2016)
|
4
28
|
|
5
29
|
- Add in GitlabCI Runner support (@davidcollum)
|
data/README.md
CHANGED
@@ -10,7 +10,8 @@
|
|
10
10
|
[documentation](http://rubydoc.info/gems/gitlab/frames) |
|
11
11
|
[gitlab-live](https://github.com/NARKOZ/gitlab-live)
|
12
12
|
|
13
|
-
Gitlab is a Ruby wrapper and CLI for the [GitLab API](https://
|
13
|
+
Gitlab is a Ruby wrapper and CLI for the [GitLab API](https://docs.gitlab.com/ce/api/README.html).
|
14
|
+
As of version `4.0.0` this gem will only support Ruby 2.0+ and Gitlab API v4.
|
14
15
|
|
15
16
|
## Installation
|
16
17
|
|
@@ -33,7 +34,7 @@ Configuration example:
|
|
33
34
|
|
34
35
|
```ruby
|
35
36
|
Gitlab.configure do |config|
|
36
|
-
config.endpoint = 'https://example.net/api/
|
37
|
+
config.endpoint = 'https://example.net/api/v4' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
|
37
38
|
config.private_token = 'qEsq1pt6HJPaNciie3MG' # user's private token or OAuth2 access token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
|
38
39
|
# Optional
|
39
40
|
# config.user_agent = 'Custom User Agent' # user agent, default: 'Gitlab Ruby Gem [version]'
|
@@ -41,14 +42,14 @@ Gitlab.configure do |config|
|
|
41
42
|
end
|
42
43
|
```
|
43
44
|
|
44
|
-
(Note: If you are using
|
45
|
+
(Note: If you are using GitLab.com's hosted service, your endpoint will be `https://gitlab.com/api/v4`)
|
45
46
|
|
46
47
|
Usage examples:
|
47
48
|
|
48
49
|
```ruby
|
49
50
|
# set an API endpoint
|
50
|
-
Gitlab.endpoint = 'http://example.net/api/
|
51
|
-
# => "http://example.net/api/
|
51
|
+
Gitlab.endpoint = 'http://example.net/api/v4'
|
52
|
+
# => "http://example.net/api/v4"
|
52
53
|
|
53
54
|
# set a user private token
|
54
55
|
Gitlab.private_token = 'qEsq1pt6HJPaNciie3MG'
|
@@ -107,7 +108,7 @@ For more information, refer to [documentation](http://rubydoc.info/gems/gitlab/f
|
|
107
108
|
|
108
109
|
It is possible to use this gem as a command line interface to gitlab. In order to make that work you need to set a few environment variables:
|
109
110
|
```sh
|
110
|
-
export GITLAB_API_ENDPOINT=https://gitlab.yourcompany.com/api/
|
111
|
+
export GITLAB_API_ENDPOINT=https://gitlab.yourcompany.com/api/v4
|
111
112
|
export GITLAB_API_PRIVATE_TOKEN=<your private token from /profile/account>
|
112
113
|
# This one is optional and can be used to set any HTTParty option you may need
|
113
114
|
# using YAML hash syntax. For example, this is how you would disable SSL
|
data/gitlab.gemspec
CHANGED
@@ -19,12 +19,10 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
gem.license = "BSD"
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
gem.add_runtime_dependency 'terminal-table'
|
22
|
+
gem.required_ruby_version = ">= 2.0.0"
|
23
|
+
|
24
|
+
gem.add_runtime_dependency 'httparty'
|
25
|
+
gem.add_runtime_dependency 'terminal-table', '1.7.1'
|
28
26
|
|
29
27
|
gem.add_development_dependency 'pry'
|
30
28
|
gem.add_development_dependency 'rake'
|
data/lib/gitlab/client.rb
CHANGED
@@ -15,6 +15,7 @@ module Gitlab
|
|
15
15
|
include Milestones
|
16
16
|
include Namespaces
|
17
17
|
include Notes
|
18
|
+
include Pipelines
|
18
19
|
include Projects
|
19
20
|
include Repositories
|
20
21
|
include RepositoryFiles
|
@@ -24,5 +25,28 @@ module Gitlab
|
|
24
25
|
include SystemHooks
|
25
26
|
include Tags
|
26
27
|
include Users
|
28
|
+
|
29
|
+
# Text representation of the client, masking private token.
|
30
|
+
#
|
31
|
+
# @return [String]
|
32
|
+
def inspect
|
33
|
+
inspected = super
|
34
|
+
|
35
|
+
if @private_token
|
36
|
+
inspected = inspected.sub! @private_token, only_show_last_four_chars(@private_token)
|
37
|
+
end
|
38
|
+
|
39
|
+
inspected
|
40
|
+
end
|
41
|
+
|
42
|
+
def url_encode(s)
|
43
|
+
ERB::Util.url_encode(s)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def only_show_last_four_chars(token)
|
49
|
+
"#{'*'*(token.size - 4)}#{token[-4..-1]}"
|
50
|
+
end
|
27
51
|
end
|
28
52
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
class Gitlab::Client
|
2
2
|
# Defines methods related to repositories.
|
3
|
-
# @see https://
|
3
|
+
# @see https://docs.gitlab.com/ce/api/branches.html
|
4
4
|
module Branches
|
5
5
|
# Gets a list of project repositiory branches.
|
6
6
|
#
|
7
7
|
# @example
|
8
8
|
# Gitlab.branches(42)
|
9
9
|
#
|
10
|
-
# @param [Integer] project The ID of a project.
|
10
|
+
# @param [Integer, String] project The ID or name of a project.
|
11
11
|
# @param [Hash] options A customizable set of options.
|
12
12
|
# @option options [Integer] :page The page number.
|
13
13
|
# @option options [Integer] :per_page The number of results per page.
|
14
14
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
15
15
|
def branches(project, options={})
|
16
|
-
get("/projects/#{project}/repository/branches", query: options)
|
16
|
+
get("/projects/#{url_encode project}/repository/branches", query: options)
|
17
17
|
end
|
18
18
|
alias_method :repo_branches, :branches
|
19
19
|
|
@@ -23,11 +23,11 @@ class Gitlab::Client
|
|
23
23
|
# Gitlab.branch(3, 'api')
|
24
24
|
# Gitlab.repo_branch(5, 'master')
|
25
25
|
#
|
26
|
-
# @param [Integer] project The ID of a project.
|
26
|
+
# @param [Integer, String] project The ID or name of a project.
|
27
27
|
# @param [String] branch The name of the branch.
|
28
28
|
# @return [Gitlab::ObjectifiedHash]
|
29
29
|
def branch(project, branch)
|
30
|
-
get("/projects/#{project}/repository/branches/#{branch}")
|
30
|
+
get("/projects/#{url_encode project}/repository/branches/#{branch}")
|
31
31
|
end
|
32
32
|
alias_method :repo_branch, :branch
|
33
33
|
|
@@ -37,11 +37,11 @@ class Gitlab::Client
|
|
37
37
|
# Gitlab.protect_branch(3, 'api')
|
38
38
|
# Gitlab.repo_protect_branch(5, 'master')
|
39
39
|
#
|
40
|
-
# @param [Integer] project The ID of a project.
|
40
|
+
# @param [Integer, String] project The ID or name of a project.
|
41
41
|
# @param [String] branch The name of the branch.
|
42
42
|
# @return [Gitlab::ObjectifiedHash]
|
43
43
|
def protect_branch(project, branch)
|
44
|
-
put("/projects/#{project}/repository/branches/#{branch}/protect")
|
44
|
+
put("/projects/#{url_encode project}/repository/branches/#{branch}/protect")
|
45
45
|
end
|
46
46
|
alias_method :repo_protect_branch, :protect_branch
|
47
47
|
|
@@ -51,11 +51,11 @@ class Gitlab::Client
|
|
51
51
|
# Gitlab.unprotect_branch(3, 'api')
|
52
52
|
# Gitlab.repo_unprotect_branch(5, 'master')
|
53
53
|
#
|
54
|
-
# @param [Integer] project The ID of a project.
|
54
|
+
# @param [Integer, String] project The ID or name of a project.
|
55
55
|
# @param [String] branch The name of the branch.
|
56
56
|
# @return [Gitlab::ObjectifiedHash]
|
57
57
|
def unprotect_branch(project, branch)
|
58
|
-
put("/projects/#{project}/repository/branches/#{branch}/unprotect")
|
58
|
+
put("/projects/#{url_encode project}/repository/branches/#{branch}/unprotect")
|
59
59
|
end
|
60
60
|
alias_method :repo_unprotect_branch, :unprotect_branch
|
61
61
|
|
@@ -65,12 +65,12 @@ class Gitlab::Client
|
|
65
65
|
# Gitlab.create_branch(3, 'api')
|
66
66
|
# Gitlab.repo_create_branch(5, 'master')
|
67
67
|
#
|
68
|
-
# @param [Integer] project The ID of a project.
|
68
|
+
# @param [Integer, String] project The ID or name of a project.
|
69
69
|
# @param [String] branch The name of the new branch.
|
70
70
|
# @param [String] ref Create branch from commit sha or existing branch
|
71
71
|
# @return [Gitlab::ObjectifiedHash]
|
72
72
|
def create_branch(project, branch, ref)
|
73
|
-
post("/projects/#{project}/repository/branches", body: { branch_name: branch, ref: ref })
|
73
|
+
post("/projects/#{url_encode project}/repository/branches", body: { branch_name: branch, ref: ref })
|
74
74
|
end
|
75
75
|
alias_method :repo_create_branch, :create_branch
|
76
76
|
|
@@ -80,11 +80,11 @@ class Gitlab::Client
|
|
80
80
|
# Gitlab.delete_branch(3, 'api')
|
81
81
|
# Gitlab.repo_delete_branch(5, 'master')
|
82
82
|
#
|
83
|
-
# @param [Integer] project The ID of a project.
|
83
|
+
# @param [Integer, String] project The ID or name of a project.
|
84
84
|
# @param [String] branch The name of the branch to delete
|
85
85
|
# @return [Gitlab::ObjectifiedHash]
|
86
86
|
def delete_branch(project, branch)
|
87
|
-
delete("/projects/#{project}/repository/branches/#{branch}")
|
87
|
+
delete("/projects/#{url_encode project}/repository/branches/#{branch}")
|
88
88
|
end
|
89
89
|
alias_method :repo_delete_branch, :delete_branch
|
90
90
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
class Gitlab::Client
|
2
2
|
# Defines methods related to builds.
|
3
|
-
# @see https://
|
3
|
+
# @see https://docs.gitlab.com/ce/api/build_triggers.html
|
4
4
|
module BuildTriggers
|
5
5
|
# Gets a list of the project's build triggers
|
6
6
|
#
|
7
7
|
# @example
|
8
8
|
# Gitlab.triggers(5)
|
9
9
|
#
|
10
|
-
# @param [Integer] project The ID of a project.
|
10
|
+
# @param [Integer, String] project The ID or name of a project.
|
11
11
|
# @return [Array<Gitlab::ObjectifiedHash>] The list of triggers.
|
12
12
|
def triggers(project)
|
13
|
-
get("/projects/#{project}/triggers")
|
13
|
+
get("/projects/#{url_encode project}/triggers")
|
14
14
|
end
|
15
15
|
|
16
16
|
# Gets details of project's build trigger.
|
@@ -18,11 +18,11 @@ class Gitlab::Client
|
|
18
18
|
# @example
|
19
19
|
# Gitlab.trigger(5, '7b9148c158980bbd9bcea92c17522d')
|
20
20
|
#
|
21
|
-
# @param [Integer] project The ID of a project.
|
21
|
+
# @param [Integer, String] project The ID or name of a project.
|
22
22
|
# @param [String] token The token of a trigger.
|
23
23
|
# @return [Gitlab::ObjectifiedHash] The trigger.
|
24
24
|
def trigger(project, token)
|
25
|
-
get("/projects/#{project}/triggers/#{token}")
|
25
|
+
get("/projects/#{url_encode project}/triggers/#{token}")
|
26
26
|
end
|
27
27
|
|
28
28
|
# Create a build trigger for a project.
|
@@ -30,10 +30,10 @@ class Gitlab::Client
|
|
30
30
|
# @example
|
31
31
|
# Gitlab.create_trigger(5)
|
32
32
|
#
|
33
|
-
# @param [Integer] project The ID of a project.
|
33
|
+
# @param [Integer, String] project The ID or name of a project.
|
34
34
|
# @return [Gitlab::ObjectifiedHash] The trigger.
|
35
35
|
def create_trigger(project)
|
36
|
-
post("/projects/#{project}/triggers")
|
36
|
+
post("/projects/#{url_encode project}/triggers")
|
37
37
|
end
|
38
38
|
|
39
39
|
# Remove a project's build trigger.
|
@@ -41,11 +41,11 @@ class Gitlab::Client
|
|
41
41
|
# @example
|
42
42
|
# Gitlab.remove_trigger(5, '7b9148c158980bbd9bcea92c17522d')
|
43
43
|
#
|
44
|
-
# @param [Integer] project The ID of a project.
|
44
|
+
# @param [Integer, String] project The ID or name of a project.
|
45
45
|
# @param [String] token The token of a trigger.
|
46
46
|
# @return [Gitlab::ObjectifiedHash] The trigger.
|
47
47
|
def remove_trigger(project, token)
|
48
|
-
delete("/projects/#{project}/triggers/#{token}")
|
48
|
+
delete("/projects/#{url_encode project}/triggers/#{token}")
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
class Gitlab::Client
|
2
2
|
# Defines methods related to builds.
|
3
|
-
# @see https://
|
3
|
+
# @see https://docs.gitlab.com/ce/api/build_variables.html
|
4
4
|
module BuildVariables
|
5
5
|
# Gets a list of the project's build variables
|
6
6
|
#
|
7
7
|
# @example
|
8
8
|
# Gitlab.variables(5)
|
9
9
|
#
|
10
|
-
# @param [Integer] project The ID of a project.
|
10
|
+
# @param [Integer, String] project The ID or name of a project.
|
11
11
|
# @return [Array<Gitlab::ObjectifiedHash>] The list of variables.
|
12
12
|
def variables(project)
|
13
|
-
get("/projects/#{project}/variables")
|
13
|
+
get("/projects/#{url_encode project}/variables")
|
14
14
|
end
|
15
15
|
|
16
16
|
# Gets details of a project's specific build variable.
|
@@ -18,11 +18,11 @@ class Gitlab::Client
|
|
18
18
|
# @example
|
19
19
|
# Gitlab.build(5, "TEST_VARIABLE_1")
|
20
20
|
#
|
21
|
-
# @param [Integer] project The ID of a project.
|
21
|
+
# @param [Integer, String] project The ID or name of a project.
|
22
22
|
# @param [String] key The key of a variable.
|
23
23
|
# @return [Gitlab::ObjectifiedHash] The variable.
|
24
24
|
def variable(project, key)
|
25
|
-
get("/projects/#{project}/variables/#{key}")
|
25
|
+
get("/projects/#{url_encode project}/variables/#{key}")
|
26
26
|
end
|
27
27
|
|
28
28
|
# Create a build variable for a project.
|
@@ -30,12 +30,12 @@ class Gitlab::Client
|
|
30
30
|
# @example
|
31
31
|
# Gitlab.create_variable(5, "NEW_VARIABLE", "new value")
|
32
32
|
#
|
33
|
-
# @param [Integer] project The ID of a project.
|
33
|
+
# @param [Integer, String] project The ID or name of a project.
|
34
34
|
# @param [String] key The key of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9` and `_` are allowed
|
35
35
|
# @param [String] value The value of a variable
|
36
36
|
# @return [Gitlab::ObjectifiedHash] The variable.
|
37
37
|
def create_variable(project, key, value)
|
38
|
-
post("/projects/#{project}/variables", body: { key: key, value: value })
|
38
|
+
post("/projects/#{url_encode project}/variables", body: { key: key, value: value })
|
39
39
|
end
|
40
40
|
|
41
41
|
# Update a project's build variable.
|
@@ -43,12 +43,12 @@ class Gitlab::Client
|
|
43
43
|
# @example
|
44
44
|
# Gitlab.create_variable(5, "NEW_VARIABLE", "updated value")
|
45
45
|
#
|
46
|
-
# @param [Integer] project The ID of a project.
|
46
|
+
# @param [Integer, String] project The ID or name of a project.
|
47
47
|
# @param [String] key The key of a variable
|
48
48
|
# @param [String] value The value of a variable
|
49
49
|
# @return [Gitlab::ObjectifiedHash] The variable.
|
50
50
|
def update_variable(project, key, value)
|
51
|
-
put("/projects/#{project}/variables/#{key}", body: { value: value })
|
51
|
+
put("/projects/#{url_encode project}/variables/#{key}", body: { value: value })
|
52
52
|
end
|
53
53
|
|
54
54
|
# Remove a project's build variable.
|
@@ -56,11 +56,11 @@ class Gitlab::Client
|
|
56
56
|
# @example
|
57
57
|
# Gitlab.remove_variable(5, "VARIABLE_1")
|
58
58
|
#
|
59
|
-
# @param [Integer] project The ID of a project.
|
59
|
+
# @param [Integer, String] project The ID or name of a project.
|
60
60
|
# @param [String] key The key of a variable.
|
61
61
|
# @return [Gitlab::ObjectifiedHash] The variable.
|
62
62
|
def remove_variable(project, key)
|
63
|
-
delete("/projects/#{project}/variables/#{key}")
|
63
|
+
delete("/projects/#{url_encode project}/variables/#{key}")
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
data/lib/gitlab/client/builds.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Gitlab::Client
|
2
2
|
# Defines methods related to builds.
|
3
|
-
# @see https://
|
3
|
+
# @see https://docs.gitlab.com/ce/api/builds.html
|
4
4
|
module Builds
|
5
5
|
# Gets a list of project builds.
|
6
6
|
#
|
@@ -8,14 +8,14 @@ class Gitlab::Client
|
|
8
8
|
# Gitlab.builds(5)
|
9
9
|
# Gitlab.builds(5, { per_page: 10, page: 2 })
|
10
10
|
#
|
11
|
-
# @param [Integer] project The ID of a project.
|
11
|
+
# @param [Integer, String] project The ID or name of a project.
|
12
12
|
# @param [Hash] options A customizable set of options.
|
13
13
|
# @option options [Integer] :page The page number.
|
14
14
|
# @option options [Integer] :per_page The number of results per page.
|
15
|
-
# @param [Integer] project The ID of a project.
|
15
|
+
# @param [Integer, String] project The ID or name of a project.
|
16
16
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
17
17
|
def builds(project, options={})
|
18
|
-
get("/projects/#{project}/builds", query: options)
|
18
|
+
get("/projects/#{url_encode project}/builds", query: options)
|
19
19
|
end
|
20
20
|
|
21
21
|
# Gets a single build.
|
@@ -23,11 +23,11 @@ class Gitlab::Client
|
|
23
23
|
# @example
|
24
24
|
# Gitlab.build(5, 36)
|
25
25
|
#
|
26
|
-
# @param [Integer] project The ID of a project.
|
26
|
+
# @param [Integer, String] project The ID or name of a project.
|
27
27
|
# @param [Integer] id The ID of a build.
|
28
28
|
# @return [Gitlab::ObjectifiedHash]
|
29
29
|
def build(project, id)
|
30
|
-
get("/projects/#{project}/builds/#{id}")
|
30
|
+
get("/projects/#{url_encode project}/builds/#{id}")
|
31
31
|
end
|
32
32
|
|
33
33
|
# Gets build artifacts.
|
@@ -35,11 +35,11 @@ class Gitlab::Client
|
|
35
35
|
# @example
|
36
36
|
# Gitlab.build_artifacts(1, 8)
|
37
37
|
#
|
38
|
-
# @param [Integer] project The ID of a project.
|
38
|
+
# @param [Integer, String] project The ID or name of a project.
|
39
39
|
# @param [Integer] id The ID of a build.
|
40
40
|
# @return [Gitlab::FileResponse]
|
41
41
|
def build_artifacts(project, id)
|
42
|
-
get("/projects/#{project}/builds/#{id}/artifacts",
|
42
|
+
get("/projects/#{url_encode project}/builds/#{id}/artifacts",
|
43
43
|
format: nil,
|
44
44
|
headers: { Accept: 'application/octet-stream' },
|
45
45
|
parser: proc { |body, _|
|
@@ -57,14 +57,14 @@ class Gitlab::Client
|
|
57
57
|
# Gitlab.commit_builds(5, 'asdf')
|
58
58
|
# Gitlab.commit_builds(5, 'asdf', { per_page: 10, page: 2 })
|
59
59
|
#
|
60
|
-
# @param [Integer] project The ID of a project.
|
60
|
+
# @param [Integer, String] project The ID or name of a project.
|
61
61
|
# @param [String] sha The SHA checksum of a commit.
|
62
62
|
# @param [Hash] options A customizable set of options.
|
63
63
|
# @option options [Integer] :page The page number.
|
64
64
|
# @option options [Integer] :per_page The number of results per page.
|
65
65
|
# @return [Array<Gitlab::ObjectifiedHash>] The list of builds.
|
66
66
|
def commit_builds(project, sha, options={})
|
67
|
-
get("/projects/#{project}/repository/commits/#{sha}/builds", query: options)
|
67
|
+
get("/projects/#{url_encode project}/repository/commits/#{sha}/builds", query: options)
|
68
68
|
end
|
69
69
|
|
70
70
|
# Cancels a build.
|
@@ -72,11 +72,11 @@ class Gitlab::Client
|
|
72
72
|
# @example
|
73
73
|
# Gitlab.build_cancel(5, 1)
|
74
74
|
#
|
75
|
-
# @param [Integer] project The ID of a project.
|
75
|
+
# @param [Integer, String] project The ID or name of a project.
|
76
76
|
# @param [Integer] id The ID of a build.
|
77
77
|
# @return [Gitlab::ObjectifiedHash] The builds changes.
|
78
78
|
def build_cancel(project, id)
|
79
|
-
post("/projects/#{project}/builds/#{id}/cancel")
|
79
|
+
post("/projects/#{url_encode project}/builds/#{id}/cancel")
|
80
80
|
end
|
81
81
|
|
82
82
|
# Retry a build.
|
@@ -84,11 +84,11 @@ class Gitlab::Client
|
|
84
84
|
# @example
|
85
85
|
# Gitlab.build_retry(5, 1)
|
86
86
|
#
|
87
|
-
# @param [Integer] project The ID of a project.
|
87
|
+
# @param [Integer, String] project The ID or name of a project.
|
88
88
|
# @param [Integer] id The ID of a build.
|
89
89
|
# @return [Array<Gitlab::ObjectifiedHash>] The builds changes.
|
90
90
|
def build_retry(project, id)
|
91
|
-
post("/projects/#{project}/builds/#{id}/retry")
|
91
|
+
post("/projects/#{url_encode project}/builds/#{id}/retry")
|
92
92
|
end
|
93
93
|
|
94
94
|
# Erase a single build of a project (remove build artifacts and a build trace)
|
@@ -96,11 +96,11 @@ class Gitlab::Client
|
|
96
96
|
# @example
|
97
97
|
# Gitlab.build_erase(5, 1)
|
98
98
|
#
|
99
|
-
# @param [Integer] project The ID of a project.
|
99
|
+
# @param [Integer, String] project The ID or name of a project.
|
100
100
|
# @param [Integer] id The ID of a build.
|
101
101
|
# @return [Gitlab::ObjectifiedHash] The build's changes.
|
102
102
|
def build_erase(project, id)
|
103
|
-
post("/projects/#{project}/builds/#{id}/erase")
|
103
|
+
post("/projects/#{url_encode project}/builds/#{id}/erase")
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|