blob: 005a778a36d682197c8c335e8d58753a17182890 (
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
39
40
41
42
43
44
45
46
|
# == 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: 255 }
def deploy?
job_type == "deploy"
end
def run_for_ref?(ref)
if !refs.blank?
refs.split(",").map(&:strip).each do |refs_val|
return true if File.fnmatch(refs_val, ref)
end
false
else
true
end
end
end
|