summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-05-28 14:29:21 +0300
committerValery Sizov <vsv2711@gmail.com>2015-06-03 16:35:57 +0300
commit17a8fe8a9011cfde0a9dbe70d726c769819a9dfd (patch)
tree10b048c8c2dab844f82779a2a6efdaf3811bb9f0 /app/models/commit.rb
parent54bd76399ddf5fb925df01d9f86ed020c475b3ba (diff)
downloadgitlab-ci-17a8fe8a9011cfde0a9dbe70d726c769819a9dfd.tar.gz
proof of concept yml configuration
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb45
1 files changed, 22 insertions, 23 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 6c876bd..4657564 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -93,30 +93,15 @@ class Commit < ActiveRecord::Base
end
def create_builds
- project.jobs.where(build_branches: true).active.parallel.map do |job|
- create_build_from_job(job)
+ builds_config.builds.each do |build_attrs|
+ builds.create!({project: project}.merge(build_attrs))
end
end
- def create_builds_for_tag(ref = '')
- project.jobs.where(build_tags: true).active.parallel.map do |job|
- create_build_from_job(job, ref)
- end
- end
-
- def create_build_from_job(job, ref = '')
- build = builds.new(commands: job.commands)
- build.tag_list = job.tag_list
- build.project_id = project_id
- build.job = job
- build.save
- build
- end
-
def builds_without_retry
@builds_without_retry ||=
begin
- grouped_builds = builds.group_by(&:job)
+ grouped_builds = builds.group_by(&:name)
grouped_builds.map do |job, builds|
builds.sort_by(&:id).last
end
@@ -127,14 +112,24 @@ class Commit < ActiveRecord::Base
@retried_builds ||= (builds - builds_without_retry)
end
- def create_deploy_builds(ref)
- project.jobs.deploy.active.each do |job|
- if job.run_for_ref?(ref)
- create_build_from_job(job)
- end
+ def create_deploy_builds
+ builds_config.deploy_builds.each do |build_attrs|
+ refs = build_attrs.delete(:refs)
+ next unless refs.empty? || refs_matches?(refs, ref)
+ builds.create!({project: project}.merge(build_attrs))
end
end
+ # refs - list of refs. Glob syntax is supported. Ex. ["feature*", "bug"]
+ # ref - ref that should be checked
+ def refs_matches?(refs, ref)
+ refs.map(&:strip).each do |ref_pattern|
+ return true if File.fnmatch(ref_pattern, ref)
+ end
+
+ false
+ end
+
def status
if success?
'success'
@@ -194,4 +189,8 @@ class Commit < ActiveRecord::Base
def matrix?
builds_without_retry.size > 1
end
+
+ def builds_config
+ @builds_config ||= GitlabCiYamlParser.new(push_data[:ci_yaml_file])
+ end
end