Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
efebdba2
Commit
efebdba2
authored
May 25, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Frontend implementation, tests, and changelog
parent
9f6dc8b2
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
78 additions
and
5 deletions
+78
-5
app/controllers/projects/variables_controller.rb
app/controllers/projects/variables_controller.rb
+2
-1
app/views/projects/pipelines_settings/_show.html.haml
app/views/projects/pipelines_settings/_show.html.haml
+1
-1
app/views/projects/variables/_form.html.haml
app/views/projects/variables/_form.html.haml
+9
-0
app/views/projects/variables/_table.html.haml
app/views/projects/variables/_table.html.haml
+3
-0
changelogs/unreleased/24196-protected-variables.yml
changelogs/unreleased/24196-protected-variables.yml
+5
-0
lib/gitlab/utils.rb
lib/gitlab/utils.rb
+8
-0
spec/features/variables_spec.rb
spec/features/variables_spec.rb
+43
-1
spec/lib/gitlab/utils_spec.rb
spec/lib/gitlab/utils_spec.rb
+5
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+2
-2
No files found.
app/controllers/projects/variables_controller.rb
View file @
efebdba2
...
@@ -42,6 +42,7 @@ class Projects::VariablesController < Projects::ApplicationController
...
@@ -42,6 +42,7 @@ class Projects::VariablesController < Projects::ApplicationController
private
private
def
project_params
def
project_params
params
.
require
(
:variable
).
permit
([
:id
,
:key
,
:value
,
:_destroy
])
params
.
require
(
:variable
)
.
permit
([
:id
,
:key
,
:value
,
:protected
,
:_destroy
])
end
end
end
end
app/views/projects/pipelines_settings/_show.html.haml
View file @
efebdba2
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
=
f
.
label
:build_timeout_in_minutes
,
'Timeout'
,
class:
'label-light'
=
f
.
label
:build_timeout_in_minutes
,
'Timeout'
,
class:
'label-light'
=
f
.
number_field
:build_timeout_in_minutes
,
class:
'form-control'
,
min:
'0'
=
f
.
number_field
:build_timeout_in_minutes
,
class:
'form-control'
,
min:
'0'
%p
.help-block
%p
.help-block
Per job in minutes. If a job passes this threshold, it will be marked as failed
.
Per job in minutes. If a job passes this threshold, it will be marked as failed
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'user/project/pipelines/settings'
,
anchor:
'timeout'
),
target:
'_blank'
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'user/project/pipelines/settings'
,
anchor:
'timeout'
),
target:
'_blank'
%hr
%hr
...
...
app/views/projects/variables/_form.html.haml
View file @
efebdba2
...
@@ -7,4 +7,13 @@
...
@@ -7,4 +7,13 @@
.form-group
.form-group
=
f
.
label
:value
,
"Value"
,
class:
"label-light"
=
f
.
label
:value
,
"Value"
,
class:
"label-light"
=
f
.
text_area
:value
,
class:
"form-control"
,
placeholder:
"PROJECT_VARIABLE"
=
f
.
text_area
:value
,
class:
"form-control"
,
placeholder:
"PROJECT_VARIABLE"
.form-group
.checkbox
=
f
.
label
:protected
do
=
f
.
check_box
:protected
%strong
Protected
.help-block
This variable will be passed only to pipelines running on protected branches and tags
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'ci/variables/README'
,
anchor:
'protected-variables'
),
target:
'_blank'
=
f
.
submit
btn_text
,
class:
"btn btn-save"
=
f
.
submit
btn_text
,
class:
"btn btn-save"
app/views/projects/variables/_table.html.haml
View file @
efebdba2
.table-responsive.variables-table
.table-responsive.variables-table
%table
.table
%table
.table
%colgroup
%colgroup
%col
%col
%col
%col
%col
%col
{
width:
100
}
%col
{
width:
100
}
%thead
%thead
%th
Key
%th
Key
%th
Value
%th
Value
%th
Protected
%th
%th
%tbody
%tbody
-
@project
.
variables
.
order_key_asc
.
each
do
|
variable
|
-
@project
.
variables
.
order_key_asc
.
each
do
|
variable
|
...
@@ -14,6 +16,7 @@
...
@@ -14,6 +16,7 @@
%tr
%tr
%td
.variable-key
=
variable
.
key
%td
.variable-key
=
variable
.
key
%td
.variable-value
{
"data-value"
=>
variable
.
value
}
******
%td
.variable-value
{
"data-value"
=>
variable
.
value
}
******
%td
.variable-protected
=
Gitlab
::
Utils
.
boolean_to_yes_no
(
variable
.
protected
)
%td
.variable-menu
%td
.variable-menu
=
link_to
namespace_project_variable_path
(
@project
.
namespace
,
@project
,
variable
),
class:
"btn btn-transparent btn-variable-edit"
do
=
link_to
namespace_project_variable_path
(
@project
.
namespace
,
@project
,
variable
),
class:
"btn btn-transparent btn-variable-edit"
do
%span
.sr-only
%span
.sr-only
...
...
changelogs/unreleased/24196-protected-variables.yml
0 → 100644
View file @
efebdba2
---
title
:
Add protected variables which would only be passed to protected branches or
protected tags
merge_request
:
11688
author
:
lib/gitlab/utils.rb
View file @
efebdba2
...
@@ -21,5 +21,13 @@ module Gitlab
...
@@ -21,5 +21,13 @@ module Gitlab
nil
nil
end
end
def
boolean_to_yes_no
(
bool
)
if
bool
'Yes'
else
'No'
end
end
end
end
end
end
spec/features/variables_spec.rb
View file @
efebdba2
...
@@ -19,7 +19,7 @@ describe 'Project variables', js: true do
...
@@ -19,7 +19,7 @@ describe 'Project variables', js: true do
end
end
end
end
it
'adds new variable'
do
it
'adds new
secret
variable'
do
fill_in
(
'variable_key'
,
with:
'key'
)
fill_in
(
'variable_key'
,
with:
'key'
)
fill_in
(
'variable_value'
,
with:
'key value'
)
fill_in
(
'variable_value'
,
with:
'key value'
)
click_button
(
'Add new variable'
)
click_button
(
'Add new variable'
)
...
@@ -27,6 +27,7 @@ describe 'Project variables', js: true do
...
@@ -27,6 +27,7 @@ describe 'Project variables', js: true do
expect
(
page
).
to
have_content
(
'Variables were successfully updated.'
)
expect
(
page
).
to
have_content
(
'Variables were successfully updated.'
)
page
.
within
(
'.variables-table'
)
do
page
.
within
(
'.variables-table'
)
do
expect
(
page
).
to
have_content
(
'key'
)
expect
(
page
).
to
have_content
(
'key'
)
expect
(
page
).
to
have_content
(
'No'
)
end
end
end
end
...
@@ -41,6 +42,19 @@ describe 'Project variables', js: true do
...
@@ -41,6 +42,19 @@ describe 'Project variables', js: true do
end
end
end
end
it
'adds new protected variable'
do
fill_in
(
'variable_key'
,
with:
'key'
)
fill_in
(
'variable_value'
,
with:
'value'
)
check
(
'Protected'
)
click_button
(
'Add new variable'
)
expect
(
page
).
to
have_content
(
'Variables were successfully updated.'
)
page
.
within
(
'.variables-table'
)
do
expect
(
page
).
to
have_content
(
'key'
)
expect
(
page
).
to
have_content
(
'Yes'
)
end
end
it
'reveals and hides new variable'
do
it
'reveals and hides new variable'
do
fill_in
(
'variable_key'
,
with:
'key'
)
fill_in
(
'variable_key'
,
with:
'key'
)
fill_in
(
'variable_value'
,
with:
'key value'
)
fill_in
(
'variable_value'
,
with:
'key value'
)
...
@@ -100,4 +114,32 @@ describe 'Project variables', js: true do
...
@@ -100,4 +114,32 @@ describe 'Project variables', js: true do
expect
(
page
).
to
have_content
(
'Variable was successfully updated.'
)
expect
(
page
).
to
have_content
(
'Variable was successfully updated.'
)
expect
(
project
.
variables
.
first
.
value
).
to
eq
(
''
)
expect
(
project
.
variables
.
first
.
value
).
to
eq
(
''
)
end
end
it
'edits variable to be protected'
do
page
.
within
(
'.variables-table'
)
do
find
(
'.btn-variable-edit'
).
click
end
expect
(
page
).
to
have_content
(
'Update variable'
)
check
(
'Protected'
)
click_button
(
'Save variable'
)
expect
(
page
).
to
have_content
(
'Variable was successfully updated.'
)
expect
(
project
.
variables
.
first
).
to
be_protected
end
it
'edits variable to be unprotected'
do
project
.
variables
.
first
.
update
(
protected:
true
)
page
.
within
(
'.variables-table'
)
do
find
(
'.btn-variable-edit'
).
click
end
expect
(
page
).
to
have_content
(
'Update variable'
)
check
(
'Protected'
)
click_button
(
'Save variable'
)
expect
(
page
).
to
have_content
(
'Variable was successfully updated.'
)
expect
(
project
.
variables
.
first
).
not_to
be_protected
end
end
end
spec/lib/gitlab/utils_spec.rb
View file @
efebdba2
...
@@ -29,5 +29,10 @@ describe Gitlab::Utils, lib: true do
...
@@ -29,5 +29,10 @@ describe Gitlab::Utils, lib: true do
expect
(
to_boolean
(
''
)).
to
be_nil
expect
(
to_boolean
(
''
)).
to
be_nil
expect
(
to_boolean
(
nil
)).
to
be_nil
expect
(
to_boolean
(
nil
)).
to
be_nil
end
end
it
'converts booleans to Yes or No'
do
expect
(
boolean_to_yes_no
(
true
)).
to
eq
(
'Yes'
)
expect
(
boolean_to_yes_no
(
false
)).
to
eq
(
'No'
)
end
end
end
end
end
spec/models/project_spec.rb
View file @
efebdba2
...
@@ -1726,7 +1726,7 @@ describe Project, models: true do
...
@@ -1726,7 +1726,7 @@ describe Project, models: true do
expect
(
project
.
secret_variables
).
to
eq
(
expect
(
project
.
secret_variables
).
to
eq
(
[{
key:
secret_variable
.
key
,
[{
key:
secret_variable
.
key
,
value:
secret_variable
.
value
,
value:
secret_variable
.
value
,
public:
false
}
])
public:
false
}])
end
end
end
end
...
@@ -1735,7 +1735,7 @@ describe Project, models: true do
...
@@ -1735,7 +1735,7 @@ describe Project, models: true do
expect
(
project
.
protected_variables
).
to
eq
(
expect
(
project
.
protected_variables
).
to
eq
(
[{
key:
protected_variable
.
key
,
[{
key:
protected_variable
.
key
,
value:
protected_variable
.
value
,
value:
protected_variable
.
value
,
public:
false
}
])
public:
false
}])
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment