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
Jérome Perrin
gitlab-ce
Commits
06f01073
Commit
06f01073
authored
Jun 21, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pipeline_schedule_variables model/db
parent
8bc8e01f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
30 deletions
+24
-30
app/models/ci/build.rb
app/models/ci/build.rb
+7
-7
app/models/ci/pipeline_schedule_variable.rb
app/models/ci/pipeline_schedule_variable.rb
+0
-1
db/migrate/20170620064728_create_ci_pipeline_schedule_variables.rb
...e/20170620064728_create_ci_pipeline_schedule_variables.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+15
-20
spec/models/ci/pipeline_schedule_variable_spec.rb
spec/models/ci/pipeline_schedule_variable_spec.rb
+1
-1
No files found.
app/models/ci/build.rb
View file @
06f01073
...
@@ -176,12 +176,9 @@ module Ci
...
@@ -176,12 +176,9 @@ module Ci
# * Lowercased
# * Lowercased
# * Anything not matching [a-z0-9-] is replaced with a -
# * Anything not matching [a-z0-9-] is replaced with a -
# * Maximum length is 63 bytes
# * Maximum length is 63 bytes
# * First/Last Character is not a hyphen
def
ref_slug
def
ref_slug
ref
.
to_s
slugified
=
ref
.
to_s
.
downcase
.
downcase
slugified
.
gsub
(
/[^a-z0-9]/
,
'-'
)[
0
..
62
]
.
gsub
(
/[^a-z0-9]/
,
'-'
)[
0
..
62
]
.
gsub
(
/(\A-+|-+\z)/
,
''
)
end
end
# Variables whose value does not depend on environment
# Variables whose value does not depend on environment
...
@@ -195,8 +192,11 @@ module Ci
...
@@ -195,8 +192,11 @@ module Ci
variables
+=
yaml_variables
variables
+=
yaml_variables
variables
+=
user_variables
variables
+=
user_variables
variables
+=
project
.
secret_variables_for
(
ref
).
map
(
&
:to_runner_variable
)
variables
+=
project
.
secret_variables_for
(
ref
).
map
(
&
:to_runner_variable
)
variables
+=
trigger_request
.
user_variables
if
trigger_request
if
trigger_request
variables
+=
pipeline
.
pipeline_schedule
.
job_variables
if
pipeline
.
pipeline_schedule
variables
+=
trigger_request
.
user_variables
elsif
pipeline
.
pipeline_schedule
variables
+=
pipeline
.
pipeline_schedule
.
variables
.
map
(
&
:to_runner_variable
)
end
variables
variables
end
end
...
...
app/models/ci/pipeline_schedule_variable.rb
View file @
06f01073
...
@@ -4,7 +4,6 @@ module Ci
...
@@ -4,7 +4,6 @@ module Ci
include
HasVariable
include
HasVariable
belongs_to
:pipeline_schedule
belongs_to
:pipeline_schedule
validates
:key
,
uniqueness:
{
scope: :pipeline_schedule_id
}
validates
:key
,
uniqueness:
{
scope: :pipeline_schedule_id
}
end
end
end
end
db/migrate/20170620064728_create_ci_pipeline_schedule_variables.rb
View file @
06f01073
...
@@ -10,7 +10,7 @@ class CreateCiPipelineScheduleVariables < ActiveRecord::Migration
...
@@ -10,7 +10,7 @@ class CreateCiPipelineScheduleVariables < ActiveRecord::Migration
t
.
string
:encrypted_value_iv
t
.
string
:encrypted_value_iv
t
.
integer
:pipeline_schedule_id
,
null:
false
t
.
integer
:pipeline_schedule_id
,
null:
false
t
.
timestamps
_with_timezone
null:
tru
e
t
.
timestamps
null:
fals
e
end
end
add_index
:ci_pipeline_schedule_variables
,
add_index
:ci_pipeline_schedule_variables
,
...
...
spec/models/ci/build_spec.rb
View file @
06f01073
...
@@ -1004,11 +1004,7 @@ describe Ci::Build, :models do
...
@@ -1004,11 +1004,7 @@ describe Ci::Build, :models do
'fix-1-foo'
=>
'fix-1-foo'
,
'fix-1-foo'
=>
'fix-1-foo'
,
'a'
*
63
=>
'a'
*
63
,
'a'
*
63
=>
'a'
*
63
,
'a'
*
64
=>
'a'
*
63
,
'a'
*
64
=>
'a'
*
63
,
'FOO'
=>
'foo'
,
'FOO'
=>
'foo'
'-'
+
'a'
*
61
+
'-'
=>
'a'
*
61
,
'-'
+
'a'
*
62
+
'-'
=>
'a'
*
62
,
'-'
+
'a'
*
63
+
'-'
=>
'a'
*
62
,
'a'
*
62
+
' '
=>
'a'
*
62
}.
each
do
|
ref
,
slug
|
}.
each
do
|
ref
,
slug
|
it
"transforms
#{
ref
}
to
#{
slug
}
"
do
it
"transforms
#{
ref
}
to
#{
slug
}
"
do
build
.
ref
=
ref
build
.
ref
=
ref
...
@@ -1373,21 +1369,20 @@ describe Ci::Build, :models do
...
@@ -1373,21 +1369,20 @@ describe Ci::Build, :models do
it
{
is_expected
.
to
include
(
predefined_trigger_variable
)
}
it
{
is_expected
.
to
include
(
predefined_trigger_variable
)
}
end
end
context
'when a job was triggered by a pipeline schedule'
do
context
'when build was triggered by scheduled pipeline'
do
let
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
project:
project
)
}
let
(
:secret_variable
)
do
{
key:
'SECRET_KEY'
,
value:
'secret_value'
,
public:
false
}
let!
(
:pipeline_schedule_variable
)
do
create
(
:ci_pipeline_schedule_variable
,
key:
'SCHEDULE_VARIABLE_KEY'
,
pipeline_schedule:
pipeline_schedule
)
end
end
let
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
project:
project
)
}
before
do
before
do
pipeline_schedule
.
pipelines
<<
pipeline
pipeline_schedule
.
pipelines
<<
pipeline
pipeline_schedule
.
reload
create
(
:ci_pipeline_schedule_variable
,
secret_variable
.
slice
(
:key
,
:value
).
merge
(
pipeline_schedule:
pipeline_schedule
))
end
end
it
{
is_expected
.
to
include
(
pipeline_schedule_variable
.
to_runner
_variable
)
}
it
{
is_expected
.
to
include
(
secret
_variable
)
}
end
end
context
'when yaml_variables are undefined'
do
context
'when yaml_variables are undefined'
do
...
...
spec/models/ci/pipeline_schedule_variable_spec.rb
View file @
06f01073
...
@@ -3,6 +3,6 @@ require 'spec_helper'
...
@@ -3,6 +3,6 @@ require 'spec_helper'
describe
Ci
::
PipelineScheduleVariable
,
models:
true
do
describe
Ci
::
PipelineScheduleVariable
,
models:
true
do
subject
{
build
(
:ci_pipeline_schedule_variable
)
}
subject
{
build
(
:ci_pipeline_schedule_variable
)
}
it
{
is_expected
.
to
include_module
(
HasVariable
)
}
it
{
is_expected
.
to
be_kind_of
(
HasVariable
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:key
).
scoped_to
(
:pipeline_schedule_id
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:key
).
scoped_to
(
:pipeline_schedule_id
)
}
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