gitlab 4.2.0 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +33 -0
- data/.travis.yml +8 -3
- data/README.md +7 -7
- data/Rakefile +11 -3
- data/gitlab.gemspec +11 -11
- data/lib/gitlab.rb +2 -2
- data/lib/gitlab/api.rb +2 -1
- data/lib/gitlab/cli.rb +2 -6
- data/lib/gitlab/cli_helpers.rb +18 -20
- data/lib/gitlab/client.rb +8 -5
- data/lib/gitlab/client/branches.rb +4 -4
- data/lib/gitlab/client/build_variables.rb +64 -2
- data/lib/gitlab/client/deployments.rb +32 -0
- data/lib/gitlab/client/groups.rb +49 -0
- data/lib/gitlab/client/issues.rb +71 -0
- data/lib/gitlab/client/merge_requests.rb +1 -0
- data/lib/gitlab/client/pipeline_schedules.rb +133 -0
- data/lib/gitlab/client/pipeline_triggers.rb +2 -2
- data/lib/gitlab/client/projects.rb +1 -1
- data/lib/gitlab/client/repository_files.rb +2 -2
- data/lib/gitlab/client/users.rb +5 -5
- data/lib/gitlab/configuration.rb +2 -2
- data/lib/gitlab/error.rb +10 -2
- data/lib/gitlab/file_response.rb +1 -1
- data/lib/gitlab/help.rb +5 -6
- data/lib/gitlab/page_links.rb +2 -2
- data/lib/gitlab/request.rb +34 -50
- data/lib/gitlab/shell.rb +5 -8
- data/lib/gitlab/version.rb +1 -1
- data/spec/fixtures/deployment.json +57 -0
- data/spec/fixtures/deployments.json +116 -0
- data/spec/fixtures/group_edit.json +14 -0
- data/spec/fixtures/group_subgroups.json +16 -0
- data/spec/fixtures/pipeline_schedule.json +32 -0
- data/spec/fixtures/pipeline_schedule_create.json +21 -0
- data/spec/fixtures/pipeline_schedule_update.json +26 -0
- data/spec/fixtures/pipeline_schedule_variable.json +5 -0
- data/spec/fixtures/pipeline_schedule_variable_update.json +5 -0
- data/spec/fixtures/pipeline_schedules.json +22 -0
- data/spec/gitlab/api_spec.rb +11 -0
- data/spec/gitlab/cli_helpers_spec.rb +14 -15
- data/spec/gitlab/cli_spec.rb +11 -11
- data/spec/gitlab/client/award_emojis_spec.rb +55 -55
- data/spec/gitlab/client/boards_spec.rb +12 -12
- data/spec/gitlab/client/branches_spec.rb +22 -22
- data/spec/gitlab/client/build_variables_spec.rb +93 -10
- data/spec/gitlab/client/builds_spec.rb +36 -36
- data/spec/gitlab/client/commits_spec.rb +21 -21
- data/spec/gitlab/client/deployments_spec.rb +38 -0
- data/spec/gitlab/client/environments_spec.rb +18 -18
- data/spec/gitlab/client/groups_spec.rb +73 -22
- data/spec/gitlab/client/issues_spec.rb +121 -22
- data/spec/gitlab/client/jobs_spec.rb +13 -13
- data/spec/gitlab/client/keys_spec.rb +2 -2
- data/spec/gitlab/client/labels_spec.rb +12 -12
- data/spec/gitlab/client/merge_requests_spec.rb +23 -23
- data/spec/gitlab/client/milestones_spec.rb +12 -12
- data/spec/gitlab/client/namespaces_spec.rb +3 -3
- data/spec/gitlab/client/notes_spec.rb +40 -40
- data/spec/gitlab/client/pipeline_schedules_spec.rb +158 -0
- data/spec/gitlab/client/pipeline_triggers_spec.rb +17 -17
- data/spec/gitlab/client/pipelines_spec.rb +22 -22
- data/spec/gitlab/client/projects_spec.rb +75 -75
- data/spec/gitlab/client/repositories_spec.rb +16 -16
- data/spec/gitlab/client/repository_files_spec.rb +10 -10
- data/spec/gitlab/client/runners_spec.rb +20 -22
- data/spec/gitlab/client/services_spec.rb +6 -6
- data/spec/gitlab/client/snippets_spec.rb +12 -12
- data/spec/gitlab/client/system_hooks_spec.rb +12 -12
- data/spec/gitlab/client/tags_spec.rb +19 -20
- data/spec/gitlab/client/todos_spec.rb +12 -12
- data/spec/gitlab/client/users_spec.rb +49 -49
- data/spec/gitlab/error_spec.rb +50 -23
- data/spec/gitlab/file_response_spec.rb +6 -6
- data/spec/gitlab/help_spec.rb +5 -5
- data/spec/gitlab/objectified_hash_spec.rb +8 -8
- data/spec/gitlab/page_links_spec.rb +1 -1
- data/spec/gitlab/paginated_response_spec.rb +4 -4
- data/spec/gitlab/request_spec.rb +19 -19
- data/spec/gitlab/shell_spec.rb +12 -12
- data/spec/gitlab_spec.rb +13 -14
- data/spec/spec_helper.rb +10 -45
- metadata +46 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4bfad0b28f61c172f39cceece1d908d7bbd6a339dfd94bde1fd2fd91894947c4
|
4
|
+
data.tar.gz: 991192468932b419e0f7512ac0034a942a994fe09ab66372f195332e81fbc639
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c769c30e5072d68696fe7cc75747744aa6ff28a232f7084eb96cc78dbe4853a213d456a95d3a635197ef4a9473ddfd5fd7379654a6a1811c6b74b87f6c62a37
|
7
|
+
data.tar.gz: 48292a8b7dafad7fbaf577bcff3065b97beeb47610e68d513544f66f48881b0bd291cfa5110835a52d177927a6ee8a4acc8b0d8bb48d0b595951bc1a2b1032d8
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Style/Alias:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Style/PercentLiteralDelimiters:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Layout/DotPosition:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/LineLength:
|
14
|
+
Max: 100
|
15
|
+
Exclude:
|
16
|
+
- 'lib/gitlab/client/*'
|
17
|
+
- 'spec/**/*'
|
18
|
+
|
19
|
+
Style/ClassAndModuleChildren:
|
20
|
+
Exclude:
|
21
|
+
- 'lib/gitlab/client/*'
|
22
|
+
|
23
|
+
Layout/SpaceInsideHashLiteralBraces:
|
24
|
+
Exclude:
|
25
|
+
- 'lib/gitlab/client/*'
|
26
|
+
|
27
|
+
Style/StringLiterals:
|
28
|
+
Exclude:
|
29
|
+
- 'spec/**/*'
|
30
|
+
|
31
|
+
Metrics/BlockLength:
|
32
|
+
Exclude:
|
33
|
+
- 'spec/**/*'
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# Gitlab
|
2
2
|
|
3
|
-
[![Build Status](https://img.shields.io/travis/NARKOZ/gitlab.svg
|
4
|
-
[![Code Climate](https://img.shields.io/codeclimate/
|
5
|
-
[![Inline docs](http://inch-ci.org/github/NARKOZ/gitlab.svg
|
6
|
-
[![Gem version](https://img.shields.io/gem/v/gitlab.svg
|
7
|
-
[![License](https://img.shields.io/badge/license-BSD-red.svg
|
3
|
+
[![Build Status](https://img.shields.io/travis/NARKOZ/gitlab.svg)](https://travis-ci.org/NARKOZ/gitlab)
|
4
|
+
[![Code Climate](https://img.shields.io/codeclimate/maintainability/NARKOZ/gitlab.svg)](https://codeclimate.com/github/NARKOZ/gitlab)
|
5
|
+
[![Inline docs](http://inch-ci.org/github/NARKOZ/gitlab.svg)](https://inch-ci.org/github/NARKOZ/gitlab)
|
6
|
+
[![Gem version](https://img.shields.io/gem/v/gitlab.svg)](https://rubygems.org/gems/gitlab)
|
7
|
+
[![License](https://img.shields.io/badge/license-BSD-red.svg)](https://github.com/NARKOZ/gitlab/blob/master/LICENSE.txt)
|
8
8
|
|
9
9
|
[website](http://narkoz.github.io/gitlab) |
|
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://docs.gitlab.com/ce/api/README.html).
|
14
|
-
As of version `4.0.0` this gem
|
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 only supports Ruby 2.0+ and Gitlab API v4.
|
15
15
|
|
16
16
|
## Installation
|
17
17
|
|
data/Rakefile
CHANGED
@@ -1,9 +1,17 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
|
3
3
|
require 'rspec/core/rake_task'
|
4
4
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
5
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
6
5
|
spec.rspec_opts = ['--color', '--format d']
|
7
6
|
end
|
8
7
|
|
9
|
-
|
8
|
+
require 'rubocop/rake_task'
|
9
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
10
|
+
task.options = ['-D', '--parallel']
|
11
|
+
end
|
12
|
+
|
13
|
+
if ENV['TRAVIS_CI_RUBOCOP']
|
14
|
+
task default: :rubocop
|
15
|
+
else
|
16
|
+
task default: :spec
|
17
|
+
end
|
data/gitlab.gemspec
CHANGED
@@ -1,25 +1,24 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'gitlab/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name =
|
6
|
+
gem.name = 'gitlab'
|
8
7
|
gem.version = Gitlab::VERSION
|
9
|
-
gem.authors = [
|
10
|
-
gem.email = [
|
11
|
-
gem.description =
|
12
|
-
gem.summary =
|
13
|
-
gem.homepage =
|
8
|
+
gem.authors = ['Nihad Abbasov']
|
9
|
+
gem.email = ['mail@narkoz.me']
|
10
|
+
gem.description = 'Ruby client and CLI for GitLab API'
|
11
|
+
gem.summary = 'A Ruby wrapper and CLI for the GitLab API'
|
12
|
+
gem.homepage = 'https://github.com/narkoz/gitlab'
|
14
13
|
|
15
14
|
gem.files = `git ls-files`.split($/)
|
16
|
-
gem.bindir =
|
15
|
+
gem.bindir = 'exe'
|
17
16
|
gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
-
gem.require_paths = [
|
20
|
-
gem.license =
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
gem.license = 'BSD'
|
21
20
|
|
22
|
-
gem.required_ruby_version =
|
21
|
+
gem.required_ruby_version = '>= 2.0.0'
|
23
22
|
|
24
23
|
gem.add_runtime_dependency 'httparty'
|
25
24
|
gem.add_runtime_dependency 'terminal-table'
|
@@ -28,4 +27,5 @@ Gem::Specification.new do |gem|
|
|
28
27
|
gem.add_development_dependency 'rake'
|
29
28
|
gem.add_development_dependency 'rspec'
|
30
29
|
gem.add_development_dependency 'webmock'
|
30
|
+
gem.add_development_dependency 'rubocop'
|
31
31
|
end
|
data/lib/gitlab.rb
CHANGED
@@ -26,7 +26,7 @@ module Gitlab
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# Delegate to Gitlab::Client
|
29
|
-
def respond_to_missing?(method_name, include_private
|
29
|
+
def self.respond_to_missing?(method_name, include_private=false)
|
30
30
|
client.respond_to?(method_name) || super
|
31
31
|
end
|
32
32
|
|
@@ -39,7 +39,7 @@ module Gitlab
|
|
39
39
|
#
|
40
40
|
# @return [Array<Symbol>]
|
41
41
|
def self.actions
|
42
|
-
hidden = /endpoint|private_token|auth_token|user_agent|sudo|get|post|put|\Adelete\z|validate|
|
42
|
+
hidden = /endpoint|private_token|auth_token|user_agent|sudo|get|post|put|\Adelete\z|validate|request_defaults|httparty/
|
43
43
|
(Gitlab::Client.instance_methods - Object.methods).reject { |e| e[hidden] }
|
44
44
|
end
|
45
45
|
end
|
data/lib/gitlab/api.rb
CHANGED
@@ -13,7 +13,8 @@ module Gitlab
|
|
13
13
|
(Configuration::VALID_OPTIONS_KEYS + [:auth_token]).each do |key|
|
14
14
|
send("#{key}=", options[key]) if options[key]
|
15
15
|
end
|
16
|
-
|
16
|
+
request_defaults(@sudo)
|
17
|
+
self.class.headers 'User-Agent' => user_agent
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/lib/gitlab/cli.rb
CHANGED
@@ -52,15 +52,11 @@ class Gitlab::CLI
|
|
52
52
|
end
|
53
53
|
|
54
54
|
unless valid_command?(cmd)
|
55
|
-
puts
|
55
|
+
puts 'Unknown command. Run `gitlab help` for a list of available commands.'
|
56
56
|
exit(1)
|
57
57
|
end
|
58
58
|
|
59
|
-
|
60
|
-
command_args = args[0..-2]
|
61
|
-
else
|
62
|
-
command_args = args
|
63
|
-
end
|
59
|
+
command_args = args.any? && args.last.start_with?('--only=', '--except=') ? args[0..-2] : args
|
64
60
|
|
65
61
|
begin
|
66
62
|
command_args.map! { |arg| symbolize_keys(yaml_load(arg)) }
|
data/lib/gitlab/cli_helpers.rb
CHANGED
@@ -67,14 +67,15 @@ class Gitlab::CLI
|
|
67
67
|
#
|
68
68
|
# @return [String]
|
69
69
|
def confirm_command(cmd)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
70
|
+
return unless cmd.start_with?('remove_', 'delete_')
|
71
|
+
|
72
|
+
puts 'Are you sure? (y/n)'
|
73
|
+
|
74
|
+
if %w(y yes).include?($stdin.gets.to_s.strip.downcase)
|
75
|
+
puts 'Proceeding..'
|
76
|
+
else
|
77
|
+
puts 'Command aborted.'
|
78
|
+
exit(1)
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
@@ -102,17 +103,17 @@ class Gitlab::CLI
|
|
102
103
|
end
|
103
104
|
|
104
105
|
def output_json(cmd, args, data)
|
105
|
-
if data.empty?
|
106
|
+
if data.respond_to?(:empty?) && data.empty?
|
106
107
|
puts '{}'
|
107
108
|
else
|
108
109
|
hash_result = case data
|
109
|
-
when Gitlab::ObjectifiedHash,Gitlab::FileResponse
|
110
|
+
when Gitlab::ObjectifiedHash, Gitlab::FileResponse
|
110
111
|
record_hash([data], cmd, args, true)
|
111
112
|
when Gitlab::PaginatedResponse
|
112
113
|
record_hash(data, cmd, args)
|
113
114
|
else
|
114
115
|
{ cmd: cmd, data: data, args: args }
|
115
|
-
|
116
|
+
end
|
116
117
|
puts JSON.pretty_generate(hash_result)
|
117
118
|
end
|
118
119
|
end
|
@@ -135,7 +136,7 @@ class Gitlab::CLI
|
|
135
136
|
keys.each do |key|
|
136
137
|
case value = hash[key]
|
137
138
|
when Hash
|
138
|
-
value = value.
|
139
|
+
value = value.key?('id') ? value['id'] : 'Hash'
|
139
140
|
when StringIO
|
140
141
|
value = 'File'
|
141
142
|
when nil
|
@@ -194,7 +195,7 @@ class Gitlab::CLI
|
|
194
195
|
# Helper function to get rows and keys from data returned from API call
|
195
196
|
def get_keys(args, data)
|
196
197
|
arr = data.map(&:to_h)
|
197
|
-
keys = arr.first.keys.
|
198
|
+
keys = arr.first.keys.sort_by(&:to_s)
|
198
199
|
keys &= required_fields(args) if required_fields(args).any?
|
199
200
|
keys -= excluded_fields(args)
|
200
201
|
[arr, keys]
|
@@ -220,7 +221,7 @@ class Gitlab::CLI
|
|
220
221
|
begin
|
221
222
|
newhash[key.to_sym] = symbolize_keys(value)
|
222
223
|
rescue NoMethodError
|
223
|
-
raise "
|
224
|
+
raise "Error: cannot convert hash key to symbol: #{key}"
|
224
225
|
end
|
225
226
|
end
|
226
227
|
end
|
@@ -230,12 +231,9 @@ class Gitlab::CLI
|
|
230
231
|
|
231
232
|
# YAML::load on a single argument
|
232
233
|
def yaml_load(arg)
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
raise "error: Argument is not valid YAML syntax: #{arg}"
|
237
|
-
end
|
238
|
-
yaml
|
234
|
+
YAML.safe_load(arg)
|
235
|
+
rescue Psych::SyntaxError
|
236
|
+
raise "Error: Argument is not valid YAML syntax: #{arg}"
|
239
237
|
end
|
240
238
|
end
|
241
239
|
end
|
data/lib/gitlab/client.rb
CHANGED
@@ -3,23 +3,27 @@ module Gitlab
|
|
3
3
|
class Client < API
|
4
4
|
Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f }
|
5
5
|
|
6
|
+
# Please keep in alphabetical order
|
6
7
|
include AwardEmojis
|
7
8
|
include Boards
|
8
9
|
include Branches
|
9
|
-
include Builds
|
10
10
|
include BuildVariables
|
11
|
+
include Builds
|
11
12
|
include Commits
|
13
|
+
include Deployments
|
12
14
|
include Environments
|
13
15
|
include Groups
|
14
16
|
include Issues
|
17
|
+
include Jobs
|
15
18
|
include Keys
|
16
19
|
include Labels
|
17
20
|
include MergeRequests
|
18
21
|
include Milestones
|
19
22
|
include Namespaces
|
20
23
|
include Notes
|
21
|
-
include
|
24
|
+
include PipelineSchedules
|
22
25
|
include PipelineTriggers
|
26
|
+
include Pipelines
|
23
27
|
include Projects
|
24
28
|
include Repositories
|
25
29
|
include RepositoryFiles
|
@@ -30,7 +34,6 @@ module Gitlab
|
|
30
34
|
include Tags
|
31
35
|
include Todos
|
32
36
|
include Users
|
33
|
-
include Jobs
|
34
37
|
|
35
38
|
# Text representation of the client, masking private token.
|
36
39
|
#
|
@@ -46,13 +49,13 @@ module Gitlab
|
|
46
49
|
end
|
47
50
|
|
48
51
|
def url_encode(s)
|
49
|
-
|
52
|
+
URI.encode(s.to_s, /\W/)
|
50
53
|
end
|
51
54
|
|
52
55
|
private
|
53
56
|
|
54
57
|
def only_show_last_four_chars(token)
|
55
|
-
"#{'*'*(token.size - 4)}#{token[-4..-1]}"
|
58
|
+
"#{'*' * (token.size - 4)}#{token[-4..-1]}"
|
56
59
|
end
|
57
60
|
end
|
58
61
|
end
|
@@ -27,7 +27,7 @@ class Gitlab::Client
|
|
27
27
|
# @param [String] branch The name of the branch.
|
28
28
|
# @return [Gitlab::ObjectifiedHash]
|
29
29
|
def branch(project, branch)
|
30
|
-
get("/projects/#{url_encode project}/repository/branches/#{branch}")
|
30
|
+
get("/projects/#{url_encode project}/repository/branches/#{url_encode branch}")
|
31
31
|
end
|
32
32
|
alias_method :repo_branch, :branch
|
33
33
|
|
@@ -47,7 +47,7 @@ class Gitlab::Client
|
|
47
47
|
# @option options [Boolean] :developers_can_merge True to allow developers to merge into the branch (default = false)
|
48
48
|
# @return [Gitlab::ObjectifiedHash] Details about the branch
|
49
49
|
def protect_branch(project, branch, options = {})
|
50
|
-
|
50
|
+
post("/projects/#{url_encode project}/protected_branches", body: {name: branch}.merge(options))
|
51
51
|
end
|
52
52
|
alias_method :repo_protect_branch, :protect_branch
|
53
53
|
|
@@ -61,7 +61,7 @@ class Gitlab::Client
|
|
61
61
|
# @param [String] branch The name of the branch.
|
62
62
|
# @return [Gitlab::ObjectifiedHash] Details about the branch
|
63
63
|
def unprotect_branch(project, branch)
|
64
|
-
|
64
|
+
delete("/projects/#{url_encode project}/protected_branches/#{url_encode branch}")
|
65
65
|
end
|
66
66
|
alias_method :repo_unprotect_branch, :unprotect_branch
|
67
67
|
|
@@ -89,7 +89,7 @@ class Gitlab::Client
|
|
89
89
|
# @param [Integer, String] project The ID or name of a project.
|
90
90
|
# @param [String] branch The name of the branch to delete
|
91
91
|
def delete_branch(project, branch)
|
92
|
-
delete("/projects/#{url_encode project}/repository/branches/#{branch}")
|
92
|
+
delete("/projects/#{url_encode project}/repository/branches/#{url_encode branch}")
|
93
93
|
end
|
94
94
|
alias_method :repo_delete_branch, :delete_branch
|
95
95
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
class Gitlab::Client
|
2
2
|
# Defines methods related to builds.
|
3
3
|
# @see https://docs.gitlab.com/ce/api/build_variables.html
|
4
|
+
# @see https://docs.gitlab.com/ee/api/group_level_variables.html
|
4
5
|
module BuildVariables
|
5
6
|
# Gets a list of the project's build variables
|
6
7
|
#
|
@@ -16,7 +17,7 @@ class Gitlab::Client
|
|
16
17
|
# Gets details of a project's specific build variable.
|
17
18
|
#
|
18
19
|
# @example
|
19
|
-
# Gitlab.
|
20
|
+
# Gitlab.variable(5, "TEST_VARIABLE_1")
|
20
21
|
#
|
21
22
|
# @param [Integer, String] project The ID or name of a project.
|
22
23
|
# @param [String] key The key of a variable.
|
@@ -41,7 +42,7 @@ class Gitlab::Client
|
|
41
42
|
# Update a project's build variable.
|
42
43
|
#
|
43
44
|
# @example
|
44
|
-
# Gitlab.
|
45
|
+
# Gitlab.update_variable(5, "NEW_VARIABLE", "updated value")
|
45
46
|
#
|
46
47
|
# @param [Integer, String] project The ID or name of a project.
|
47
48
|
# @param [String] key The key of a variable
|
@@ -62,5 +63,66 @@ class Gitlab::Client
|
|
62
63
|
def remove_variable(project, key)
|
63
64
|
delete("/projects/#{url_encode project}/variables/#{key}")
|
64
65
|
end
|
66
|
+
|
67
|
+
# Gets a list of the group's build variables
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# Gitlab.group_variables(5)
|
71
|
+
#
|
72
|
+
# @param [Integer, String] group The ID or name of a group.
|
73
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The list of variables.
|
74
|
+
def group_variables(group)
|
75
|
+
get("/groups/#{url_encode group}/variables")
|
76
|
+
end
|
77
|
+
|
78
|
+
# Gets details of a group's specific build variable.
|
79
|
+
#
|
80
|
+
# @example
|
81
|
+
# Gitlab.group_variable(5, "TEST_VARIABLE_1")
|
82
|
+
#
|
83
|
+
# @param [Integer, String] group The ID or name of a group.
|
84
|
+
# @param [String] key The key of a variable.
|
85
|
+
# @return [Gitlab::ObjectifiedHash] The variable.
|
86
|
+
def group_variable(group, key)
|
87
|
+
get("/groups/#{url_encode group}/variables/#{key}")
|
88
|
+
end
|
89
|
+
|
90
|
+
# Create a build variable for a group.
|
91
|
+
#
|
92
|
+
# @example
|
93
|
+
# Gitlab.create_group_variable(5, "NEW_VARIABLE", "new value")
|
94
|
+
#
|
95
|
+
# @param [Integer, String] group The ID or name of a group.
|
96
|
+
# @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
|
97
|
+
# @param [String] value The value of a variable
|
98
|
+
# @return [Gitlab::ObjectifiedHash] The variable.
|
99
|
+
def create_group_variable(group, key, value)
|
100
|
+
post("/groups/#{url_encode group}/variables", body: { key: key, value: value })
|
101
|
+
end
|
102
|
+
|
103
|
+
# Update a group's build variable.
|
104
|
+
#
|
105
|
+
# @example
|
106
|
+
# Gitlab.update_group_variable(5, "NEW_VARIABLE", "updated value")
|
107
|
+
#
|
108
|
+
# @param [Integer, String] group The ID or name of a group.
|
109
|
+
# @param [String] key The key of a variable
|
110
|
+
# @param [String] value The value of a variable
|
111
|
+
# @return [Gitlab::ObjectifiedHash] The variable.
|
112
|
+
def update_group_variable(group, key, value)
|
113
|
+
put("/groups/#{url_encode group}/variables/#{key}", body: { value: value })
|
114
|
+
end
|
115
|
+
|
116
|
+
# Remove a group's build variable.
|
117
|
+
#
|
118
|
+
# @example
|
119
|
+
# Gitlab.remove_group_variable(5, "VARIABLE_1")
|
120
|
+
#
|
121
|
+
# @param [Integer, String] group The ID or name of a group.
|
122
|
+
# @param [String] key The key of a variable.
|
123
|
+
# @return [Gitlab::ObjectifiedHash] The variable.
|
124
|
+
def remove_group_variable(group, key)
|
125
|
+
delete("/groups/#{url_encode group}/variables/#{key}")
|
126
|
+
end
|
65
127
|
end
|
66
128
|
end
|