summaryrefslogtreecommitdiff
path: root/app/models/ci/trigger_request.rb
blob: 5daf3dd192decd7a07aed813e22a6c8b2005ade3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Ci
  class TriggerRequest < ApplicationRecord
    extend Gitlab::Ci::Model

    belongs_to :trigger
    belongs_to :pipeline, foreign_key: :commit_id
    has_many :builds

    delegate :short_token, to: :trigger, prefix: true, allow_nil: true

    # We switched to Ci::PipelineVariable from Ci::TriggerRequest.variables.
    # Ci::TriggerRequest doesn't save variables anymore.
    validates :variables, absence: true

    serialize :variables # rubocop:disable Cop/ActiveRecordSerialize

    def user_variables
      return [] unless variables

      variables.map do |key, value|
        { key: key, value: value, public: false }
      end
    end
  end
end