gitlab-akerl 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 +20 -0
- data/.prospectus +11 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +229 -0
- data/CONTRIBUTING.md +195 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +24 -0
- data/README.md +192 -0
- data/Rakefile +9 -0
- data/bin/console +10 -0
- data/bin/setup +6 -0
- data/exe/gitlab +7 -0
- data/gitlab-akerl.gemspec +31 -0
- data/lib/gitlab.rb +45 -0
- data/lib/gitlab/api.rb +19 -0
- data/lib/gitlab/cli.rb +89 -0
- data/lib/gitlab/cli_helpers.rb +241 -0
- data/lib/gitlab/client.rb +48 -0
- data/lib/gitlab/client/branches.rb +91 -0
- data/lib/gitlab/client/build_triggers.rb +51 -0
- data/lib/gitlab/client/build_variables.rb +66 -0
- data/lib/gitlab/client/builds.rb +106 -0
- data/lib/gitlab/client/commits.rb +121 -0
- data/lib/gitlab/client/groups.rb +144 -0
- data/lib/gitlab/client/issues.rb +113 -0
- data/lib/gitlab/client/labels.rb +57 -0
- data/lib/gitlab/client/merge_requests.rb +168 -0
- data/lib/gitlab/client/milestones.rb +78 -0
- data/lib/gitlab/client/namespaces.rb +20 -0
- data/lib/gitlab/client/notes.rb +161 -0
- data/lib/gitlab/client/pipelines.rb +68 -0
- data/lib/gitlab/client/projects.rb +471 -0
- data/lib/gitlab/client/repositories.rb +78 -0
- data/lib/gitlab/client/repository_files.rb +88 -0
- data/lib/gitlab/client/runners.rb +115 -0
- data/lib/gitlab/client/services.rb +50 -0
- data/lib/gitlab/client/snippets.rb +91 -0
- data/lib/gitlab/client/system_hooks.rb +59 -0
- data/lib/gitlab/client/tags.rb +96 -0
- data/lib/gitlab/client/users.rb +250 -0
- data/lib/gitlab/configuration.rb +55 -0
- data/lib/gitlab/error.rb +85 -0
- data/lib/gitlab/file_response.rb +46 -0
- data/lib/gitlab/help.rb +95 -0
- data/lib/gitlab/objectified_hash.rb +34 -0
- data/lib/gitlab/page_links.rb +33 -0
- data/lib/gitlab/paginated_response.rb +97 -0
- data/lib/gitlab/request.rb +117 -0
- data/lib/gitlab/shell.rb +84 -0
- data/lib/gitlab/shell_history.rb +59 -0
- data/lib/gitlab/version.rb +3 -0
- data/spec/fixtures/branch.json +1 -0
- data/spec/fixtures/branch_delete.json +3 -0
- data/spec/fixtures/branches.json +1 -0
- data/spec/fixtures/build.json +38 -0
- data/spec/fixtures/build_artifacts.json +0 -0
- data/spec/fixtures/build_cancel.json +24 -0
- data/spec/fixtures/build_erase.json +24 -0
- data/spec/fixtures/build_retry.json +24 -0
- data/spec/fixtures/builds.json +78 -0
- data/spec/fixtures/builds_commits.json +64 -0
- data/spec/fixtures/compare_merge_request_diff.json +31 -0
- data/spec/fixtures/error_already_exists.json +1 -0
- data/spec/fixtures/error_project_not_found.json +1 -0
- data/spec/fixtures/get_repository_file.json +1 -0
- data/spec/fixtures/git_hook.json +1 -0
- data/spec/fixtures/group.json +60 -0
- data/spec/fixtures/group_create.json +1 -0
- data/spec/fixtures/group_create_with_description.json +1 -0
- data/spec/fixtures/group_delete.json +1 -0
- data/spec/fixtures/group_member.json +1 -0
- data/spec/fixtures/group_member_delete.json +1 -0
- data/spec/fixtures/group_member_edit.json +1 -0
- data/spec/fixtures/group_members.json +1 -0
- data/spec/fixtures/group_projects.json +44 -0
- data/spec/fixtures/group_search.json +2 -0
- data/spec/fixtures/groups.json +2 -0
- data/spec/fixtures/issue.json +1 -0
- data/spec/fixtures/issues.json +1 -0
- data/spec/fixtures/key.json +1 -0
- data/spec/fixtures/keys.json +1 -0
- data/spec/fixtures/label.json +1 -0
- data/spec/fixtures/labels.json +1 -0
- data/spec/fixtures/merge_request.json +1 -0
- data/spec/fixtures/merge_request_changes.json +1 -0
- data/spec/fixtures/merge_request_comment.json +1 -0
- data/spec/fixtures/merge_request_comments.json +1 -0
- data/spec/fixtures/merge_request_commits.json +1 -0
- data/spec/fixtures/merge_requests.json +1 -0
- data/spec/fixtures/milestone.json +1 -0
- data/spec/fixtures/milestone_issues.json +1 -0
- data/spec/fixtures/milestones.json +1 -0
- data/spec/fixtures/namespaces.json +1 -0
- data/spec/fixtures/note.json +1 -0
- data/spec/fixtures/notes.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.json +1 -0
- data/spec/fixtures/project_commit.json +13 -0
- data/spec/fixtures/project_commit_comment.json +1 -0
- data/spec/fixtures/project_commit_comments.json +1 -0
- data/spec/fixtures/project_commit_diff.json +10 -0
- data/spec/fixtures/project_commit_status.json +42 -0
- data/spec/fixtures/project_commits.json +1 -0
- data/spec/fixtures/project_edit.json +21 -0
- data/spec/fixtures/project_events.json +1 -0
- data/spec/fixtures/project_for_user.json +1 -0
- data/spec/fixtures/project_fork.json +50 -0
- data/spec/fixtures/project_fork_link.json +1 -0
- data/spec/fixtures/project_forked_for_user.json +50 -0
- data/spec/fixtures/project_hook.json +1 -0
- data/spec/fixtures/project_hooks.json +1 -0
- data/spec/fixtures/project_issues.json +1 -0
- data/spec/fixtures/project_key.json +6 -0
- data/spec/fixtures/project_keys.json +6 -0
- data/spec/fixtures/project_runner_enable.json +7 -0
- data/spec/fixtures/project_runners.json +16 -0
- data/spec/fixtures/project_search.json +1 -0
- data/spec/fixtures/project_star.json +44 -0
- data/spec/fixtures/project_tag_annotated.json +1 -0
- data/spec/fixtures/project_tag_lightweight.json +1 -0
- data/spec/fixtures/project_tags.json +1 -0
- data/spec/fixtures/project_unstar.json +44 -0
- data/spec/fixtures/project_update_commit_status.json +20 -0
- data/spec/fixtures/projects.json +1 -0
- data/spec/fixtures/raw_file.json +2 -0
- data/spec/fixtures/release_create.json +1 -0
- data/spec/fixtures/release_update.json +1 -0
- data/spec/fixtures/repository_file.json +1 -0
- data/spec/fixtures/runner.json +26 -0
- data/spec/fixtures/runner_delete.json +7 -0
- data/spec/fixtures/runner_edit.json +26 -0
- data/spec/fixtures/runners.json +16 -0
- data/spec/fixtures/runners_all.json +30 -0
- data/spec/fixtures/service.json +1 -0
- data/spec/fixtures/session.json +1 -0
- data/spec/fixtures/shell_history.json +2 -0
- data/spec/fixtures/snippet.json +1 -0
- data/spec/fixtures/snippet_content.json +3 -0
- data/spec/fixtures/snippets.json +1 -0
- data/spec/fixtures/system_hook.json +1 -0
- data/spec/fixtures/system_hooks.json +1 -0
- data/spec/fixtures/tag.json +1 -0
- data/spec/fixtures/tag_create.json +1 -0
- data/spec/fixtures/tag_create_with_description.json +1 -0
- data/spec/fixtures/tag_delete.json +1 -0
- data/spec/fixtures/tags.json +1 -0
- data/spec/fixtures/team_member.json +1 -0
- data/spec/fixtures/team_members.json +1 -0
- data/spec/fixtures/tree.json +1 -0
- data/spec/fixtures/trigger.json +7 -0
- data/spec/fixtures/triggers.json +16 -0
- data/spec/fixtures/user.json +1 -0
- data/spec/fixtures/user_block_unblock.json +1 -0
- data/spec/fixtures/user_email.json +1 -0
- data/spec/fixtures/user_emails.json +1 -0
- data/spec/fixtures/user_search.json +1 -0
- data/spec/fixtures/users.json +1 -0
- data/spec/fixtures/variable.json +4 -0
- data/spec/fixtures/variables.json +10 -0
- data/spec/gitlab/cli_helpers_spec.rb +57 -0
- data/spec/gitlab/cli_spec.rb +110 -0
- data/spec/gitlab/client/branches_spec.rb +99 -0
- data/spec/gitlab/client/build_triggers_spec.rb +67 -0
- data/spec/gitlab/client/build_variables_spec.rb +86 -0
- data/spec/gitlab/client/builds_spec.rb +148 -0
- data/spec/gitlab/client/client_spec.rb +11 -0
- data/spec/gitlab/client/commits_spec.rb +137 -0
- data/spec/gitlab/client/groups_spec.rb +197 -0
- data/spec/gitlab/client/issues_spec.rb +138 -0
- data/spec/gitlab/client/labels_spec.rb +68 -0
- data/spec/gitlab/client/merge_requests_spec.rb +177 -0
- data/spec/gitlab/client/milestones_spec.rb +82 -0
- data/spec/gitlab/client/namespaces_spec.rb +22 -0
- data/spec/gitlab/client/notes_spec.rb +205 -0
- data/spec/gitlab/client/pipelines_spec.rb +95 -0
- data/spec/gitlab/client/projects_spec.rb +603 -0
- data/spec/gitlab/client/repositories_spec.rb +109 -0
- data/spec/gitlab/client/repository_files_spec.rb +62 -0
- data/spec/gitlab/client/runners_spec.rb +185 -0
- data/spec/gitlab/client/services_spec.rb +55 -0
- data/spec/gitlab/client/snippets_spec.rb +100 -0
- data/spec/gitlab/client/system_hooks_spec.rb +69 -0
- data/spec/gitlab/client/tags_spec.rb +109 -0
- data/spec/gitlab/client/users_spec.rb +418 -0
- data/spec/gitlab/error_spec.rb +45 -0
- data/spec/gitlab/file_response_spec.rb +33 -0
- data/spec/gitlab/help_spec.rb +46 -0
- data/spec/gitlab/objectified_hash_spec.rb +48 -0
- data/spec/gitlab/page_links_spec.rb +16 -0
- data/spec/gitlab/paginated_response_spec.rb +60 -0
- data/spec/gitlab/request_spec.rb +73 -0
- data/spec/gitlab/shell_history_spec.rb +53 -0
- data/spec/gitlab/shell_spec.rb +80 -0
- data/spec/gitlab_spec.rb +97 -0
- data/spec/spec_helper.rb +74 -0
- metadata +476 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
class Gitlab::Client
|
|
2
|
+
# Defines methods related to builds.
|
|
3
|
+
# @see https://docs.gitlab.com/ce/api/builds.html
|
|
4
|
+
module Builds
|
|
5
|
+
# Gets a list of project builds.
|
|
6
|
+
#
|
|
7
|
+
# @example
|
|
8
|
+
# Gitlab.builds(5)
|
|
9
|
+
# Gitlab.builds(5, { per_page: 10, page: 2 })
|
|
10
|
+
#
|
|
11
|
+
# @param [Integer] project The ID of a project.
|
|
12
|
+
# @param [Hash] options A customizable set of options.
|
|
13
|
+
# @option options [Integer] :page The page number.
|
|
14
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
15
|
+
# @param [Integer] project The ID of a project.
|
|
16
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
17
|
+
def builds(project, options={})
|
|
18
|
+
get("/projects/#{project}/builds", query: options)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Gets a single build.
|
|
22
|
+
#
|
|
23
|
+
# @example
|
|
24
|
+
# Gitlab.build(5, 36)
|
|
25
|
+
#
|
|
26
|
+
# @param [Integer] project The ID of a project.
|
|
27
|
+
# @param [Integer] id The ID of a build.
|
|
28
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
29
|
+
def build(project, id)
|
|
30
|
+
get("/projects/#{project}/builds/#{id}")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Gets build artifacts.
|
|
34
|
+
#
|
|
35
|
+
# @example
|
|
36
|
+
# Gitlab.build_artifacts(1, 8)
|
|
37
|
+
#
|
|
38
|
+
# @param [Integer] project The ID of a project.
|
|
39
|
+
# @param [Integer] id The ID of a build.
|
|
40
|
+
# @return [Gitlab::FileResponse]
|
|
41
|
+
def build_artifacts(project, id)
|
|
42
|
+
get("/projects/#{project}/builds/#{id}/artifacts",
|
|
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
|
+
|
|
54
|
+
# Gets a list of builds for specific commit in a project.
|
|
55
|
+
#
|
|
56
|
+
# @example
|
|
57
|
+
# Gitlab.commit_builds(5, 'asdf')
|
|
58
|
+
# Gitlab.commit_builds(5, 'asdf', { per_page: 10, page: 2 })
|
|
59
|
+
#
|
|
60
|
+
# @param [Integer] project The ID of a project.
|
|
61
|
+
# @param [String] sha The SHA checksum of a commit.
|
|
62
|
+
# @param [Hash] options A customizable set of options.
|
|
63
|
+
# @option options [Integer] :page The page number.
|
|
64
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
65
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The list of builds.
|
|
66
|
+
def commit_builds(project, sha, options={})
|
|
67
|
+
get("/projects/#{project}/repository/commits/#{sha}/builds", query: options)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Cancels a build.
|
|
71
|
+
#
|
|
72
|
+
# @example
|
|
73
|
+
# Gitlab.build_cancel(5, 1)
|
|
74
|
+
#
|
|
75
|
+
# @param [Integer] project The ID of a project.
|
|
76
|
+
# @param [Integer] id The ID of a build.
|
|
77
|
+
# @return [Gitlab::ObjectifiedHash] The builds changes.
|
|
78
|
+
def build_cancel(project, id)
|
|
79
|
+
post("/projects/#{project}/builds/#{id}/cancel")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Retry a build.
|
|
83
|
+
#
|
|
84
|
+
# @example
|
|
85
|
+
# Gitlab.build_retry(5, 1)
|
|
86
|
+
#
|
|
87
|
+
# @param [Integer] project The ID of a project.
|
|
88
|
+
# @param [Integer] id The ID of a build.
|
|
89
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The builds changes.
|
|
90
|
+
def build_retry(project, id)
|
|
91
|
+
post("/projects/#{project}/builds/#{id}/retry")
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Erase a single build of a project (remove build artifacts and a build trace)
|
|
95
|
+
#
|
|
96
|
+
# @example
|
|
97
|
+
# Gitlab.build_erase(5, 1)
|
|
98
|
+
#
|
|
99
|
+
# @param [Integer] project The ID of a project.
|
|
100
|
+
# @param [Integer] id The ID of a build.
|
|
101
|
+
# @return [Gitlab::ObjectifiedHash] The build's changes.
|
|
102
|
+
def build_erase(project, id)
|
|
103
|
+
post("/projects/#{project}/builds/#{id}/erase")
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
class Gitlab::Client
|
|
2
|
+
# Defines methods related to repository commits.
|
|
3
|
+
# @see https://docs.gitlab.com/ce/api/commits.html
|
|
4
|
+
module Commits
|
|
5
|
+
# Gets a list of project commits.
|
|
6
|
+
#
|
|
7
|
+
# @example
|
|
8
|
+
# Gitlab.commits('viking')
|
|
9
|
+
# Gitlab.repo_commits('gitlab', { ref_name: 'api' })
|
|
10
|
+
#
|
|
11
|
+
# @param [Integer] project The ID of a project.
|
|
12
|
+
# @param [Hash] options A customizable set of options.
|
|
13
|
+
# @option options [String] :ref_name The branch or tag name of a project repository.
|
|
14
|
+
# @option options [Integer] :page The page number.
|
|
15
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
16
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
17
|
+
def commits(project, options={})
|
|
18
|
+
get("/projects/#{project}/repository/commits", query: options)
|
|
19
|
+
end
|
|
20
|
+
alias_method :repo_commits, :commits
|
|
21
|
+
|
|
22
|
+
# Gets a specific commit identified by the commit hash or name of a branch or tag.
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
# Gitlab.commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
|
26
|
+
# Gitlab.repo_commit(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
|
|
27
|
+
#
|
|
28
|
+
# @param [Integer] project The ID of a project.
|
|
29
|
+
# @param [String] sha The commit hash or name of a repository branch or tag
|
|
30
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
31
|
+
def commit(project, sha)
|
|
32
|
+
get("/projects/#{project}/repository/commits/#{sha}")
|
|
33
|
+
end
|
|
34
|
+
alias_method :repo_commit, :commit
|
|
35
|
+
|
|
36
|
+
# Get the diff of a commit in a project.
|
|
37
|
+
#
|
|
38
|
+
# @example
|
|
39
|
+
# Gitlab.commit_diff(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
|
40
|
+
# Gitlab.repo_commit_diff(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
|
|
41
|
+
#
|
|
42
|
+
# @param [Integer] project The ID of a project.
|
|
43
|
+
# @param [String] sha The name of a repository branch or tag or if not given the default branch.
|
|
44
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
45
|
+
def commit_diff(project, sha)
|
|
46
|
+
get("/projects/#{project}/repository/commits/#{sha}/diff")
|
|
47
|
+
end
|
|
48
|
+
alias_method :repo_commit_diff, :commit_diff
|
|
49
|
+
|
|
50
|
+
# Gets a list of comments for a commit.
|
|
51
|
+
#
|
|
52
|
+
# @example
|
|
53
|
+
# Gitlab.commit_comments(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b')
|
|
54
|
+
#
|
|
55
|
+
# @param [Integer] project The ID of a project.
|
|
56
|
+
# @param [String] sha The commit hash or name of a repository branch or tag.
|
|
57
|
+
# @option options [Integer] :page The page number.
|
|
58
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
59
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
60
|
+
def commit_comments(project, commit, options={})
|
|
61
|
+
get("/projects/#{project}/repository/commits/#{commit}/comments", query: options)
|
|
62
|
+
end
|
|
63
|
+
alias_method :repo_commit_comments, :commit_comments
|
|
64
|
+
|
|
65
|
+
# Creates a new comment for a commit.
|
|
66
|
+
#
|
|
67
|
+
# @example
|
|
68
|
+
# Gitlab.create_commit_comment(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b', 'Nice work on this commit!')
|
|
69
|
+
#
|
|
70
|
+
# @param [Integer] project The ID of a project.
|
|
71
|
+
# @param [String] sha The commit hash or name of a repository branch or tag.
|
|
72
|
+
# @param [String] note The text of a comment.
|
|
73
|
+
# @param [Hash] options A customizable set of options.
|
|
74
|
+
# @option options [String] :path The file path.
|
|
75
|
+
# @option options [Integer] :line The line number.
|
|
76
|
+
# @option options [String] :line_type The line type (new or old).
|
|
77
|
+
# @return [Gitlab::ObjectifiedHash] Information about created comment.
|
|
78
|
+
def create_commit_comment(project, commit, note, options={})
|
|
79
|
+
post("/projects/#{project}/repository/commits/#{commit}/comments", body: options.merge(note: note))
|
|
80
|
+
end
|
|
81
|
+
alias_method :repo_create_commit_comment, :create_commit_comment
|
|
82
|
+
|
|
83
|
+
# Get the status of a commit
|
|
84
|
+
#
|
|
85
|
+
# @example
|
|
86
|
+
# Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
|
87
|
+
# Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', { name: 'jenkins' })
|
|
88
|
+
# Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', { name: 'jenkins', all: true })
|
|
89
|
+
#
|
|
90
|
+
# @param [Integer] project The ID of a project.
|
|
91
|
+
# @param [String] sha The commit hash
|
|
92
|
+
# @param [Hash] options A customizable set of options.
|
|
93
|
+
# @option options [String] :ref Filter by ref name, it can be branch or tag
|
|
94
|
+
# @option options [String] :stage Filter by stage
|
|
95
|
+
# @option options [String] :name Filter by status name, eg. jenkins
|
|
96
|
+
# @option options [Boolean] :all The flag to return all statuses, not only latest ones
|
|
97
|
+
def commit_status(id, sha, options={})
|
|
98
|
+
get("/projects/#{id}/repository/commits/#{sha}/statuses", query: options)
|
|
99
|
+
end
|
|
100
|
+
alias_method :repo_commit_status, :commit_status
|
|
101
|
+
|
|
102
|
+
# Adds or updates a status of a commit.
|
|
103
|
+
#
|
|
104
|
+
# @example
|
|
105
|
+
# Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'success')
|
|
106
|
+
# Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'failed', { name: 'jenkins' })
|
|
107
|
+
# Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'canceled', { name: 'jenkins', target_url: 'http://example.com/builds/1' })
|
|
108
|
+
#
|
|
109
|
+
# @param [Integer] project The ID of a project.
|
|
110
|
+
# @param [String] sha The commit hash
|
|
111
|
+
# @param [String] state of the status. Can be: pending, running, success, failed, canceled
|
|
112
|
+
# @param [Hash] options A customizable set of options.
|
|
113
|
+
# @option options [String] :ref The ref (branch or tag) to which the status refers
|
|
114
|
+
# @option options [String] :name Filter by status name, eg. jenkins
|
|
115
|
+
# @option options [String] :target_url The target URL to associate with this status
|
|
116
|
+
def update_commit_status(id, sha, state, options={})
|
|
117
|
+
post("/projects/#{id}/statuses/#{sha}", query: options.merge(state: state))
|
|
118
|
+
end
|
|
119
|
+
alias_method :repo_update_commit_status, :update_commit_status
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
class Gitlab::Client
|
|
2
|
+
# Defines methods related to groups.
|
|
3
|
+
# @see https://docs.gitlab.com/ce/api/groups.html
|
|
4
|
+
module Groups
|
|
5
|
+
# Gets a list of groups.
|
|
6
|
+
#
|
|
7
|
+
# @example
|
|
8
|
+
# Gitlab.groups
|
|
9
|
+
# Gitlab.groups({ per_page: 40, page: 2 })
|
|
10
|
+
#
|
|
11
|
+
# @param [Hash] options A customizable set of options.
|
|
12
|
+
# @option options [Integer] :page The page number.
|
|
13
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
14
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
15
|
+
def groups(options={})
|
|
16
|
+
get("/groups", query: options)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Gets a single group.
|
|
20
|
+
#
|
|
21
|
+
# @example
|
|
22
|
+
# Gitlab.group(42)
|
|
23
|
+
#
|
|
24
|
+
# @param [Integer] id The ID of a group.
|
|
25
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
26
|
+
def group(id)
|
|
27
|
+
get("/groups/#{id}")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Creates a new group.
|
|
31
|
+
#
|
|
32
|
+
# @example
|
|
33
|
+
# Gitlab.create_group('new-group', 'group-path')
|
|
34
|
+
# Gitlab.create_group('gitlab', 'gitlab-path', { description: 'New Gitlab project' })
|
|
35
|
+
#
|
|
36
|
+
# @param [String] name The name of a group.
|
|
37
|
+
# @param [String] path The path of a group.
|
|
38
|
+
# @return [Gitlab::ObjectifiedHash] Information about created group.
|
|
39
|
+
def create_group(name, path, options={})
|
|
40
|
+
body = { name: name, path: path }.merge(options)
|
|
41
|
+
post("/groups", body: body)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Delete's a group.
|
|
45
|
+
#
|
|
46
|
+
# @example
|
|
47
|
+
# Gitlab.delete_group(42)
|
|
48
|
+
# @param [Integer] id The ID of a group
|
|
49
|
+
# @return [Gitlab::ObjectifiedHash] Information about the deleted group.
|
|
50
|
+
def delete_group(id)
|
|
51
|
+
delete("/groups/#{id}")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Get a list of group members.
|
|
55
|
+
#
|
|
56
|
+
# @example
|
|
57
|
+
# Gitlab.group_members(1)
|
|
58
|
+
# Gitlab.group_members(1, { per_page: 40 })
|
|
59
|
+
#
|
|
60
|
+
# @param [Integer] id The ID of a group.
|
|
61
|
+
# @param [Hash] options A customizable set of options.
|
|
62
|
+
# @option options [Integer] :page The page number.
|
|
63
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
64
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
65
|
+
def group_members(id, options={})
|
|
66
|
+
get("/groups/#{id}/members", query: options)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Adds a user to group.
|
|
70
|
+
#
|
|
71
|
+
# @example
|
|
72
|
+
# Gitlab.add_group_member(1, 2, 40)
|
|
73
|
+
#
|
|
74
|
+
# @param [Integer] team_id The group id to add a member to.
|
|
75
|
+
# @param [Integer] user_id The user id of the user to add to the team.
|
|
76
|
+
# @param [Integer] access_level Project access level.
|
|
77
|
+
# @return [Gitlab::ObjectifiedHash] Information about added team member.
|
|
78
|
+
def add_group_member(team_id, user_id, access_level)
|
|
79
|
+
post("/groups/#{team_id}/members", body: { user_id: user_id, access_level: access_level })
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Edit a user of a group.
|
|
83
|
+
#
|
|
84
|
+
# @example
|
|
85
|
+
# Gitlab.edit_group_member(1, 2, 40)
|
|
86
|
+
#
|
|
87
|
+
# @param [Integer] team_id The group id of member to edit.
|
|
88
|
+
# @param [Integer] user_id The user id of the user to edit.
|
|
89
|
+
# @param [Integer] access_level Project access level.
|
|
90
|
+
# @return [Gitlab::ObjectifiedHash] Information about edited team member.
|
|
91
|
+
def edit_group_member(team_id, user_id, access_level)
|
|
92
|
+
put("/groups/#{team_id}/members/#{user_id}", body: { access_level: access_level })
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Removes user from user group.
|
|
96
|
+
#
|
|
97
|
+
# @example
|
|
98
|
+
# Gitlab.remove_group_member(1, 2)
|
|
99
|
+
#
|
|
100
|
+
# @param [Integer] team_id The group ID.
|
|
101
|
+
# @param [Integer] user_id The ID of a user.
|
|
102
|
+
# @return [Gitlab::ObjectifiedHash] Information about removed team member.
|
|
103
|
+
def remove_group_member(team_id, user_id)
|
|
104
|
+
delete("/groups/#{team_id}/members/#{user_id}")
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Transfers a project to a group
|
|
108
|
+
#
|
|
109
|
+
# @example
|
|
110
|
+
# Gitlab.transfer_project_to_group(3, 50)
|
|
111
|
+
#
|
|
112
|
+
# @param [Integer] id The ID of a group.
|
|
113
|
+
# @param [Integer] project_id The ID of a project.
|
|
114
|
+
def transfer_project_to_group(id, project_id)
|
|
115
|
+
body = { id: id, project_id: project_id }
|
|
116
|
+
post("/groups/#{id}/projects/#{project_id}", body: body)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Search for groups by name
|
|
120
|
+
#
|
|
121
|
+
# @example
|
|
122
|
+
# Gitlab.group_search('gitlab')
|
|
123
|
+
#
|
|
124
|
+
# @param [String] search A string to search for in group names and paths.
|
|
125
|
+
# @param [Hash] options A customizable set of options.
|
|
126
|
+
# @option options [String] :per_page Number of projects to return per page
|
|
127
|
+
# @option options [String] :page The page to retrieve
|
|
128
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
129
|
+
def group_search(search, options={})
|
|
130
|
+
options[:search] = search
|
|
131
|
+
get("/groups", query: options)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Get a list of projects under a group
|
|
135
|
+
# @example
|
|
136
|
+
# Gitlab.group_projects(1)
|
|
137
|
+
#
|
|
138
|
+
# @param [Integer] id The ID of a group
|
|
139
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of projects under a group
|
|
140
|
+
def group_projects(id, options={})
|
|
141
|
+
get("/groups/#{id}/projects", query: options)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
class Gitlab::Client
|
|
2
|
+
# Defines methods related to issues.
|
|
3
|
+
# @see https://docs.gitlab.com/ce/api/issues.html
|
|
4
|
+
module Issues
|
|
5
|
+
# Gets a list of user's issues.
|
|
6
|
+
# Will return a list of project's issues if project ID passed.
|
|
7
|
+
#
|
|
8
|
+
# @example
|
|
9
|
+
# Gitlab.issues
|
|
10
|
+
# Gitlab.issues(5)
|
|
11
|
+
# Gitlab.issues({ per_page: 40 })
|
|
12
|
+
#
|
|
13
|
+
# @param [Integer] project The ID of a project.
|
|
14
|
+
# @param [Hash] options A customizable set of options.
|
|
15
|
+
# @option options [Integer] :page The page number.
|
|
16
|
+
# @option options [Integer] :per_page The number of results per page.
|
|
17
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
18
|
+
def issues(project=nil, options={})
|
|
19
|
+
if project.to_i.zero?
|
|
20
|
+
get("/issues", query: options)
|
|
21
|
+
else
|
|
22
|
+
get("/projects/#{project}/issues", query: options)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Gets a single issue.
|
|
27
|
+
#
|
|
28
|
+
# @example
|
|
29
|
+
# Gitlab.issue(5, 42)
|
|
30
|
+
#
|
|
31
|
+
# @param [Integer] project The ID of a project.
|
|
32
|
+
# @param [Integer] id The ID of an issue.
|
|
33
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
34
|
+
def issue(project, id)
|
|
35
|
+
get("/projects/#{project}/issues/#{id}")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Creates a new issue.
|
|
39
|
+
#
|
|
40
|
+
# @example
|
|
41
|
+
# Gitlab.create_issue(5, 'New issue')
|
|
42
|
+
# Gitlab.create_issue(5, 'New issue', { description: 'This is a new issue', assignee_id: 42 })
|
|
43
|
+
#
|
|
44
|
+
# @param [Integer] project The ID of a project.
|
|
45
|
+
# @param [String] title The title of an issue.
|
|
46
|
+
# @param [Hash] options A customizable set of options.
|
|
47
|
+
# @option options [String] :description The description of an issue.
|
|
48
|
+
# @option options [Integer] :assignee_id The ID of a user to assign issue.
|
|
49
|
+
# @option options [Integer] :milestone_id The ID of a milestone to assign issue.
|
|
50
|
+
# @option options [String] :labels Comma-separated label names for an issue.
|
|
51
|
+
# @return [Gitlab::ObjectifiedHash] Information about created issue.
|
|
52
|
+
def create_issue(project, title, options={})
|
|
53
|
+
body = { title: title }.merge(options)
|
|
54
|
+
post("/projects/#{project}/issues", body: body)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Updates an issue.
|
|
58
|
+
#
|
|
59
|
+
# @example
|
|
60
|
+
# Gitlab.edit_issue(6, 1, { title: 'Updated title' })
|
|
61
|
+
#
|
|
62
|
+
# @param [Integer] project The ID of a project.
|
|
63
|
+
# @param [Integer] id The ID of an issue.
|
|
64
|
+
# @param [Hash] options A customizable set of options.
|
|
65
|
+
# @option options [String] :title The title of an issue.
|
|
66
|
+
# @option options [String] :description The description of an issue.
|
|
67
|
+
# @option options [Integer] :assignee_id The ID of a user to assign issue.
|
|
68
|
+
# @option options [Integer] :milestone_id The ID of a milestone to assign issue.
|
|
69
|
+
# @option options [String] :labels Comma-separated label names for an issue.
|
|
70
|
+
# @option options [String] :state_event The state event of an issue ('close' or 'reopen').
|
|
71
|
+
# @return [Gitlab::ObjectifiedHash] Information about updated issue.
|
|
72
|
+
def edit_issue(project, id, options={})
|
|
73
|
+
put("/projects/#{project}/issues/#{id}", body: options)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Closes an issue.
|
|
77
|
+
#
|
|
78
|
+
# @example
|
|
79
|
+
# Gitlab.close_issue(3, 42)
|
|
80
|
+
#
|
|
81
|
+
# @param [Integer] project The ID of a project.
|
|
82
|
+
# @param [Integer] id The ID of an issue.
|
|
83
|
+
# @return [Gitlab::ObjectifiedHash] Information about closed issue.
|
|
84
|
+
def close_issue(project, id)
|
|
85
|
+
put("/projects/#{project}/issues/#{id}", body: { state_event: 'close' })
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Reopens an issue.
|
|
89
|
+
#
|
|
90
|
+
# @example
|
|
91
|
+
# Gitlab.reopen_issue(3, 42)
|
|
92
|
+
#
|
|
93
|
+
# @param [Integer] project The ID of a project.
|
|
94
|
+
# @param [Integer] id The ID of an issue.
|
|
95
|
+
# @return [Gitlab::ObjectifiedHash] Information about reopened issue.
|
|
96
|
+
def reopen_issue(project, id)
|
|
97
|
+
put("/projects/#{project}/issues/#{id}", body: { state_event: 'reopen' })
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Deletes an issue.
|
|
101
|
+
# Only for admins and project owners
|
|
102
|
+
#
|
|
103
|
+
# @example
|
|
104
|
+
# Gitlab.delete_issue(3, 42)
|
|
105
|
+
#
|
|
106
|
+
# @param [Integer] project The ID of a project.
|
|
107
|
+
# @param [Integer] id The ID of an issue.
|
|
108
|
+
# @return [Gitlab::ObjectifiedHash] Information about deleted issue.
|
|
109
|
+
def delete_issue(project, id)
|
|
110
|
+
delete("/projects/#{project}/issues/#{id}")
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|