blob: 106e0d38b446347b6a70be42e308115685e114d0 (
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
28
29
30
31
32
33
34
35
36
37
38
|
# == Schema Information
#
# Table name: jobs
#
# id :integer not null, primary key
# project_id :integer not null
# commands :text
# active :boolean default(TRUE), not null
# created_at :datetime
# updated_at :datetime
# name :string(255)
# build_branches :boolean default(TRUE), not null
# build_tags :boolean default(FALSE), not null
# job_type :string(255) default("parallel")
# refs :string(255)
#
class Job < ActiveRecord::Base
belongs_to :project
has_many :builds
acts_as_taggable
scope :active, ->() { where(active: true) }
scope :archived, ->() { where(active: false) }
scope :parallel, ->(){ where(job_type: "parallel") }
scope :deploy, ->(){ where(job_type: "deploy") }
validate :refs, length: { maximum: 100 }
def deploy?
job_type == "deploy"
end
def run_for_ref?(ref)
refs.blank? || refs.split(",").map{|ref| ref.strip}.include?(ref)
end
end
|