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
d278da48
Commit
d278da48
authored
Jun 21, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pipeline_schedule_variables model/db
parent
5af1fcd6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
102 additions
and
1 deletion
+102
-1
app/models/ci/build.rb
app/models/ci/build.rb
+5
-1
app/models/ci/pipeline_schedule.rb
app/models/ci/pipeline_schedule.rb
+1
-0
app/models/ci/pipeline_schedule_variable.rb
app/models/ci/pipeline_schedule_variable.rb
+9
-0
db/migrate/20170620064728_create_ci_pipeline_schedule_variables.rb
...e/20170620064728_create_ci_pipeline_schedule_variables.rb
+25
-0
db/migrate/20170620065449_add_foreign_key_to_ci_pipeline_schedule_variables.rb
...5449_add_foreign_key_to_ci_pipeline_schedule_variables.rb
+15
-0
db/schema.rb
db/schema.rb
+14
-0
spec/factories/ci/pipeline_schedule_variables.rb
spec/factories/ci/pipeline_schedule_variables.rb
+8
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+16
-0
spec/models/ci/pipeline_schedule_spec.rb
spec/models/ci/pipeline_schedule_spec.rb
+1
-0
spec/models/ci/pipeline_schedule_variable_spec.rb
spec/models/ci/pipeline_schedule_variable_spec.rb
+8
-0
No files found.
app/models/ci/build.rb
View file @
d278da48
...
...
@@ -195,7 +195,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
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.rb
View file @
d278da48
...
...
@@ -9,6 +9,7 @@ module Ci
belongs_to
:owner
,
class_name:
'User'
has_one
:last_pipeline
,
->
{
order
(
id: :desc
)
},
class_name:
'Ci::Pipeline'
has_many
:pipelines
has_many
:variables
,
class_name:
'Ci::PipelineScheduleVariable'
validates
:cron
,
unless: :importing?
,
cron:
true
,
presence:
{
unless: :importing?
}
validates
:cron_timezone
,
cron_timezone:
true
,
presence:
{
unless: :importing?
}
...
...
app/models/ci/pipeline_schedule_variable.rb
0 → 100644
View file @
d278da48
module
Ci
class
PipelineScheduleVariable
<
ActiveRecord
::
Base
extend
Ci
::
Model
include
HasVariable
belongs_to
:pipeline_schedule
validates
:key
,
uniqueness:
{
scope: :pipeline_schedule_id
}
end
end
db/migrate/20170620064728_create_ci_pipeline_schedule_variables.rb
0 → 100644
View file @
d278da48
class
CreateCiPipelineScheduleVariables
<
ActiveRecord
::
Migration
DOWNTIME
=
false
def
up
create_table
:ci_pipeline_schedule_variables
do
|
t
|
t
.
string
:key
,
null:
false
t
.
text
:value
t
.
text
:encrypted_value
t
.
string
:encrypted_value_salt
t
.
string
:encrypted_value_iv
t
.
integer
:pipeline_schedule_id
,
null:
false
t
.
timestamps
null:
false
end
add_index
:ci_pipeline_schedule_variables
,
[
:pipeline_schedule_id
,
:key
],
name:
"index_ci_pipeline_schedule_variables_on_schedule_id_and_key"
,
unique:
true
end
def
down
drop_table
:ci_pipeline_schedule_variables
end
end
db/migrate/20170620065449_add_foreign_key_to_ci_pipeline_schedule_variables.rb
0 → 100644
View file @
d278da48
class
AddForeignKeyToCiPipelineScheduleVariables
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_concurrent_foreign_key
(
:ci_pipeline_schedule_variables
,
:ci_pipeline_schedules
,
column: :pipeline_schedule_id
)
end
def
down
remove_foreign_key
(
:ci_pipeline_schedule_variables
,
column: :pipeline_schedule_id
)
end
end
db/schema.rb
View file @
d278da48
...
...
@@ -253,6 +253,19 @@ ActiveRecord::Schema.define(version: 20170623080805) do
add_index
"ci_builds"
,
[
"updated_at"
],
name:
"index_ci_builds_on_updated_at"
,
using: :btree
add_index
"ci_builds"
,
[
"user_id"
],
name:
"index_ci_builds_on_user_id"
,
using: :btree
create_table
"ci_pipeline_schedule_variables"
,
force: :cascade
do
|
t
|
t
.
string
"key"
,
null:
false
t
.
text
"value"
t
.
text
"encrypted_value"
t
.
string
"encrypted_value_salt"
t
.
string
"encrypted_value_iv"
t
.
integer
"pipeline_schedule_id"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
end
add_index
"ci_pipeline_schedule_variables"
,
[
"pipeline_schedule_id"
,
"key"
],
name:
"index_ci_pipeline_schedule_variables_on_schedule_id_and_key"
,
unique:
true
,
using: :btree
create_table
"ci_pipeline_schedules"
,
force: :cascade
do
|
t
|
t
.
string
"description"
t
.
string
"ref"
...
...
@@ -1531,6 +1544,7 @@ ActiveRecord::Schema.define(version: 20170623080805) do
add_foreign_key
"chat_teams"
,
"namespaces"
,
on_delete: :cascade
add_foreign_key
"ci_builds"
,
"ci_pipelines"
,
column:
"auto_canceled_by_id"
,
name:
"fk_a2141b1522"
,
on_delete: :nullify
add_foreign_key
"ci_builds"
,
"ci_stages"
,
column:
"stage_id"
,
name:
"fk_3a9eaa254d"
,
on_delete: :cascade
add_foreign_key
"ci_pipeline_schedule_variables"
,
"ci_pipeline_schedules"
,
column:
"pipeline_schedule_id"
,
name:
"fk_41c35fda51"
,
on_delete: :cascade
add_foreign_key
"ci_pipeline_schedules"
,
"projects"
,
name:
"fk_8ead60fcc4"
,
on_delete: :cascade
add_foreign_key
"ci_pipeline_schedules"
,
"users"
,
column:
"owner_id"
,
name:
"fk_9ea99f58d2"
,
on_delete: :nullify
add_foreign_key
"ci_pipelines"
,
"ci_pipeline_schedules"
,
column:
"pipeline_schedule_id"
,
name:
"fk_3d34ab2e06"
,
on_delete: :nullify
...
...
spec/factories/ci/pipeline_schedule_variables.rb
0 → 100644
View file @
d278da48
FactoryGirl
.
define
do
factory
:ci_pipeline_schedule_variable
,
class:
Ci
::
PipelineScheduleVariable
do
sequence
(
:key
)
{
|
n
|
"VARIABLE_
#{
n
}
"
}
value
'VARIABLE_VALUE'
pipeline_schedule
factory: :ci_pipeline_schedule
end
end
spec/models/ci/build_spec.rb
View file @
d278da48
...
...
@@ -1373,6 +1373,22 @@ describe Ci::Build, :models do
it
{
is_expected
.
to
include
(
predefined_trigger_variable
)
}
end
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
create
(
:ci_pipeline_schedule_variable
,
secret_variable
.
slice
(
:key
,
:value
).
merge
(
pipeline_schedule:
pipeline_schedule
))
end
it
{
is_expected
.
to
include
(
secret_variable
)
}
end
context
'when yaml_variables are undefined'
do
before
do
build
.
yaml_variables
=
nil
...
...
spec/models/ci/pipeline_schedule_spec.rb
View file @
d278da48
...
...
@@ -5,6 +5,7 @@ describe Ci::PipelineSchedule, models: true do
it
{
is_expected
.
to
belong_to
(
:owner
)
}
it
{
is_expected
.
to
have_many
(
:pipelines
)
}
it
{
is_expected
.
to
have_many
(
:variables
)
}
it
{
is_expected
.
to
respond_to
(
:ref
)
}
it
{
is_expected
.
to
respond_to
(
:cron
)
}
...
...
spec/models/ci/pipeline_schedule_variable_spec.rb
0 → 100644
View file @
d278da48
require
'spec_helper'
describe
Ci
::
PipelineScheduleVariable
,
models:
true
do
subject
{
build
(
:ci_pipeline_schedule_variable
)
}
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