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
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
Hide 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
# * Lowercased
# * Anything not matching [a-z0-9-] is replaced with a -
# * Maximum length is 63 bytes
# * First/Last Character is not a hyphen
def
ref_slug
ref
.
to_s
.
downcase
.
gsub
(
/[^a-z0-9]/
,
'-'
)[
0
..
62
]
.
gsub
(
/(\A-+|-+\z)/
,
''
)
slugified
=
ref
.
to_s
.
downcase
slugified
.
gsub
(
/[^a-z0-9]/
,
'-'
)[
0
..
62
]
end
# Variables whose value does not depend on environment
...
...
@@ -195,8 +192,11 @@ module Ci
variables
+=
yaml_variables
variables
+=
user_variables
variables
+=
project
.
secret_variables_for
(
ref
).
map
(
&
:to_runner_variable
)
variables
+=
trigger_request
.
user_variables
if
trigger_request
variables
+=
pipeline
.
pipeline_schedule
.
job_variables
if
pipeline
.
pipeline_schedule
if
trigger_request
variables
+=
trigger_request
.
user_variables
elsif
pipeline
.
pipeline_schedule
variables
+=
pipeline
.
pipeline_schedule
.
variables
.
map
(
&
:to_runner_variable
)
end
variables
end
...
...
app/models/ci/pipeline_schedule_variable.rb
View file @
06f01073
...
...
@@ -4,7 +4,6 @@ module Ci
include
HasVariable
belongs_to
:pipeline_schedule
validates
:key
,
uniqueness:
{
scope: :pipeline_schedule_id
}
end
end
db/migrate/20170620064728_create_ci_pipeline_schedule_variables.rb
View file @
06f01073
...
...
@@ -10,7 +10,7 @@ class CreateCiPipelineScheduleVariables < ActiveRecord::Migration
t
.
string
:encrypted_value_iv
t
.
integer
:pipeline_schedule_id
,
null:
false
t
.
timestamps
_with_timezone
null:
tru
e
t
.
timestamps
null:
fals
e
end
add_index
:ci_pipeline_schedule_variables
,
...
...
spec/models/ci/build_spec.rb
View file @
06f01073
...
...
@@ -998,17 +998,13 @@ describe Ci::Build, :models do
describe
'#ref_slug'
do
{
'master'
=>
'master'
,
'1-foo'
=>
'1-foo'
,
'fix/1-foo'
=>
'fix-1-foo'
,
'fix-1-foo'
=>
'fix-1-foo'
,
'a'
*
63
=>
'a'
*
63
,
'a'
*
64
=>
'a'
*
63
,
'FOO'
=>
'foo'
,
'-'
+
'a'
*
61
+
'-'
=>
'a'
*
61
,
'-'
+
'a'
*
62
+
'-'
=>
'a'
*
62
,
'-'
+
'a'
*
63
+
'-'
=>
'a'
*
62
,
'a'
*
62
+
' '
=>
'a'
*
62
'master'
=>
'master'
,
'1-foo'
=>
'1-foo'
,
'fix/1-foo'
=>
'fix-1-foo'
,
'fix-1-foo'
=>
'fix-1-foo'
,
'a'
*
63
=>
'a'
*
63
,
'a'
*
64
=>
'a'
*
63
,
'FOO'
=>
'foo'
}.
each
do
|
ref
,
slug
|
it
"transforms
#{
ref
}
to
#{
slug
}
"
do
build
.
ref
=
ref
...
...
@@ -1373,21 +1369,20 @@ describe Ci::Build, :models do
it
{
is_expected
.
to
include
(
predefined_trigger_variable
)
}
end
context
'when a job was triggered by a pipeline schedule'
do
let
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
project:
project
)
}
let!
(
:pipeline_schedule_variable
)
do
create
(
:ci_pipeline_schedule_variable
,
key:
'SCHEDULE_VARIABLE_KEY'
,
pipeline_schedule:
pipeline_schedule
)
context
'when build was triggered by scheduled pipeline'
do
let
(
:secret_variable
)
do
{
key:
'SECRET_KEY'
,
value:
'secret_value'
,
public:
false
}
end
let
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
project:
project
)
}
before
do
pipeline_schedule
.
pipelines
<<
pipeline
pipeline_schedule
.
reload
create
(
:ci_pipeline_schedule_variable
,
secret_variable
.
slice
(
:key
,
:value
).
merge
(
pipeline_schedule:
pipeline_schedule
))
end
it
{
is_expected
.
to
include
(
pipeline_schedule_variable
.
to_runner
_variable
)
}
it
{
is_expected
.
to
include
(
secret
_variable
)
}
end
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'
describe
Ci
::
PipelineScheduleVariable
,
models:
true
do
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
)
}
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