2018-08-03 07:15:25 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-26 01:42:46 +00:00
|
|
|
module Ci
|
2019-03-28 13:17:42 +00:00
|
|
|
class TriggerRequest < ApplicationRecord
|
2017-09-06 11:13:52 +00:00
|
|
|
extend Gitlab::Ci::Model
|
2016-07-03 23:58:58 +00:00
|
|
|
|
2016-10-18 21:20:36 +00:00
|
|
|
belongs_to :trigger
|
|
|
|
belongs_to :pipeline, foreign_key: :commit_id
|
|
|
|
has_many :builds
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2018-09-04 07:51:00 +00:00
|
|
|
delegate :short_token, to: :trigger, prefix: true, allow_nil: true
|
|
|
|
|
2017-08-28 14:29:28 +00:00
|
|
|
# We switched to Ci::PipelineVariable from Ci::TriggerRequest.variables.
|
2017-08-24 08:08:32 +00:00
|
|
|
# Ci::TriggerRequest doesn't save variables anymore.
|
|
|
|
validates :variables, absence: true
|
|
|
|
|
2017-07-03 14:01:41 +00:00
|
|
|
serialize :variables # rubocop:disable Cop/ActiveRecordSerialize
|
2016-07-20 11:17:21 +00:00
|
|
|
|
|
|
|
def user_variables
|
|
|
|
return [] unless variables
|
|
|
|
|
|
|
|
variables.map do |key, value|
|
|
|
|
{ key: key, value: value, public: false }
|
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|