Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb191df

Browse files
author
Gauvain Pocentek
committed
Add support for group variables
1 parent4057644 commiteb191df

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

‎docs/gl_objects/builds.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# var list
2-
variables=project.variables.list()
2+
p_variables=project.variables.list()
3+
g_variables=group.variables.list()
34
# end var list
45

56
# var get
6-
var=project.variables.get(var_key)
7+
p_var=project.variables.get(var_key)
8+
g_var=group.variables.get(var_key)
79
# end var get
810

911
# var create
1012
var=project.variables.create({'key':'key1','value':'value1'})
13+
var=group.variables.create({'key':'key1','value':'value1'})
1114
# end var create
1215

1316
# var update
@@ -17,6 +20,7 @@
1720

1821
# var delete
1922
project.variables.delete(var_key)
23+
group.variables.delete(var_key)
2024
# or
2125
var.delete()
2226
# end var delete

‎docs/gl_objects/builds.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ Remove a trigger:
5656
:start-after: # trigger delete
5757
:end-before: # end trigger delete
5858

59-
Project variables
60-
=================
59+
Projects and groups variables
60+
=============================
6161

62-
You can associate variables to projects to modify the build/job script
63-
behavior.
62+
You can associate variables to projectsand groupsto modify the build/job
63+
scriptsbehavior.
6464

6565
Reference
6666
---------
@@ -70,6 +70,9 @@ Reference
7070
+:class:`gitlab.v4.objects.ProjectVariable`
7171
+:class:`gitlab.v4.objects.ProjectVariableManager`
7272
+:attr:`gitlab.v4.objects.Project.variables`
73+
+:class:`gitlab.v4.objects.GroupVariable`
74+
+:class:`gitlab.v4.objects.GroupVariableManager`
75+
+:attr:`gitlab.v4.objects.Group.variables`
7376

7477
* v3 API
7578

@@ -78,7 +81,10 @@ Reference
7881
+:attr:`gitlab.v3.objects.Project.variables`
7982
+:attr:`gitlab.Gitlab.project_variables`
8083

81-
* GitLab API: https://docs.gitlab.com/ce/api/project_level_variables.html
84+
* GitLab API
85+
86+
+ https://docs.gitlab.com/ce/api/project_level_variables.html
87+
+ https://docs.gitlab.com/ce/api/group_level_variables.html
8288

8389
Examples
8490
--------

‎gitlab/v4/objects.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,6 +2121,18 @@ class GroupProjectManager(GetFromListMixin, RESTManager):
21212121
'ci_enabled_first')
21222122

21232123

2124+
classGroupVariable(SaveMixin,ObjectDeleteMixin,RESTObject):
2125+
_id_attr='key'
2126+
2127+
2128+
classGroupVariableManager(CRUDMixin,RESTManager):
2129+
_path='/groups/%(group_id)s/variables'
2130+
_obj_cls=GroupVariable
2131+
_from_parent_attrs= {'group_id':'id'}
2132+
_create_attrs= (('key','value'), ('protected',))
2133+
_update_attrs= (('key','value'), ('protected',))
2134+
2135+
21242136
classGroup(SaveMixin,ObjectDeleteMixin,RESTObject):
21252137
_short_print_attr='name'
21262138
_managers= (
@@ -2129,6 +2141,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
21292141
('notificationsettings','GroupNotificationSettingsManager'),
21302142
('projects','GroupProjectManager'),
21312143
('issues','GroupIssueManager'),
2144+
('variables','GroupVariableManager'),
21322145
)
21332146

21342147
@exc.on_http_error(exc.GitlabTransferProjectError)

‎tools/python_test_v4.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@
121121

122122
group2.members.delete(gl.user.id)
123123

124+
# Group variables
125+
group1.variables.create({'key':'foo','value':'bar'})
126+
g_v=group1.variables.get('foo')
127+
assert(g_v.value=='bar')
128+
g_v.value='baz'
129+
g_v.save()
130+
g_v=group1.variables.get('foo')
131+
assert(g_v.value=='baz')
132+
assert(len(group1.variables.list())==1)
133+
g_v.delete()
134+
assert(len(group1.variables.list())==0)
135+
124136
# hooks
125137
hook=gl.hooks.create({'url':'http://whatever.com'})
126138
assert(len(gl.hooks.list())==1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp