BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
78 additions
and
5 deletions
+78
-5
variables_controller.rb
app/controllers/projects/variables_controller.rb
+2
-1
_show.html.haml
app/views/projects/pipelines_settings/_show.html.haml
+1
-1
_form.html.haml
app/views/projects/variables/_form.html.haml
+9
-0
_table.html.haml
app/views/projects/variables/_table.html.haml
+3
-0
24196-protected-variables.yml
changelogs/unreleased/24196-protected-variables.yml
+5
-0
utils.rb
lib/gitlab/utils.rb
+8
-0
variables_spec.rb
spec/features/variables_spec.rb
+43
-1
utils_spec.rb
spec/lib/gitlab/utils_spec.rb
+5
-0
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
private
def
project_params
params
.
require
(
:variable
).
permit
([
:id
,
:key
,
:value
,
:_destroy
])
params
.
require
(
:variable
)
.
permit
([
:id
,
:key
,
:value
,
:protected
,
:_destroy
])
end
end
app/views/projects/pipelines_settings/_show.html.haml
View file @
efebdba2
...
...
@@ -42,7 +42,7 @@
=
f
.
label
:build_timeout_in_minutes
,
'Timeout'
,
class:
'label-light'
=
f
.
number_field
:build_timeout_in_minutes
,
class:
'form-control'
,
min:
'0'
%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'
%hr
...
...
app/views/projects/variables/_form.html.haml
View file @
efebdba2
...
...
@@ -7,4 +7,13 @@
.form-group
=
f
.
label
:value
,
"Value"
,
class:
"label-light"
=
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"
app/views/projects/variables/_table.html.haml
View file @
efebdba2
...
...
@@ -3,10 +3,12 @@
%colgroup
%col
%col
%col
%col
{
width:
100
}
%thead
%th
Key
%th
Value
%th
Protected
%th
%tbody
-
@project
.
variables
.
order_key_asc
.
each
do
|
variable
|
...
...
@@ -14,6 +16,7 @@
%tr
%td
.variable-key
=
variable
.
key
%td
.variable-value
{
"data-value"
=>
variable
.
value
}
******
%td
.variable-protected
=
Gitlab
::
Utils
.
boolean_to_yes_no
(
variable
.
protected
)
%td
.variable-menu
=
link_to
namespace_project_variable_path
(
@project
.
namespace
,
@project
,
variable
),
class:
"btn btn-transparent btn-variable-edit"
do
%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
nil
end
def
boolean_to_yes_no
(
bool
)
if
bool
'Yes'
else
'No'
end
end
end
end
spec/features/variables_spec.rb
View file @
efebdba2
...
...
@@ -19,7 +19,7 @@ describe 'Project variables', js: true do
end
end
it
'adds new variable'
do
it
'adds new
secret
variable'
do
fill_in
(
'variable_key'
,
with:
'key'
)
fill_in
(
'variable_value'
,
with:
'key value'
)
click_button
(
'Add new variable'
)
...
...
@@ -27,6 +27,7 @@ describe 'Project variables', js: true do
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
(
'No'
)
end
end
...
...
@@ -41,6 +42,19 @@ describe 'Project variables', js: true do
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
fill_in
(
'variable_key'
,
with:
'key'
)
fill_in
(
'variable_value'
,
with:
'key value'
)
...
...
@@ -100,4 +114,32 @@ describe 'Project variables', js: true do
expect
(
page
).
to
have_content
(
'Variable was successfully updated.'
)
expect
(
project
.
variables
.
first
.
value
).
to
eq
(
''
)
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
spec/lib/gitlab/utils_spec.rb
View file @
efebdba2
...
...
@@ -29,5 +29,10 @@ describe Gitlab::Utils, lib: true do
expect
(
to_boolean
(
''
)).
to
be_nil
expect
(
to_boolean
(
nil
)).
to
be_nil
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
spec/models/project_spec.rb
View file @
efebdba2
...
...
@@ -1726,7 +1726,7 @@ describe Project, models: true do
expect
(
project
.
secret_variables
).
to
eq
(
[{
key:
secret_variable
.
key
,
value:
secret_variable
.
value
,
public:
false
}
])
public:
false
}])
end
end
...
...
@@ -1735,7 +1735,7 @@ describe Project, models: true do
expect
(
project
.
protected_variables
).
to
eq
(
[{
key:
protected_variable
.
key
,
value:
protected_variable
.
value
,
public:
false
}
])
public:
false
}])
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