summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-06-21 18:25:01 +0900
committerShinya Maeda <shinya@gitlab.com>2017-07-05 18:36:18 +0900
commitd278da48f837292491aaf81649afef1da3a1eb09 (patch)
tree3af83b99d6e6c2b503d1a73f0ac61604edf375ee /app/models
parent5af1fcd6f329858d757bab0d67cb50af6c820160 (diff)
downloadgitlab-ce-d278da48f837292491aaf81649afef1da3a1eb09.tar.gz
pipeline_schedule_variables model/db
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/build.rb6
-rw-r--r--app/models/ci/pipeline_schedule.rb1
-rw-r--r--app/models/ci/pipeline_schedule_variable.rb9
3 files changed, 15 insertions, 1 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 2e7a80d308b..06570ccb69b 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -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
diff --git a/app/models/ci/pipeline_schedule.rb b/app/models/ci/pipeline_schedule.rb
index 45d8cd34359..31b73248947 100644
--- a/app/models/ci/pipeline_schedule.rb
+++ b/app/models/ci/pipeline_schedule.rb
@@ -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? }
diff --git a/app/models/ci/pipeline_schedule_variable.rb b/app/models/ci/pipeline_schedule_variable.rb
new file mode 100644
index 00000000000..2d681446d00
--- /dev/null
+++ b/app/models/ci/pipeline_schedule_variable.rb
@@ -0,0 +1,9 @@
+module Ci
+ class PipelineScheduleVariable < ActiveRecord::Base
+ extend Ci::Model
+ include HasVariable
+
+ belongs_to :pipeline_schedule
+ validates :key, uniqueness: { scope: :pipeline_schedule_id }
+ end
+end