diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-06-16 15:12:36 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-06-17 11:35:39 +0300 |
commit | 40830fee8bcdfd465fb87fada28ef049a080acf2 (patch) | |
tree | de9b0e5351cbf0f05f04155e9ca97afa984dc456 /app/models/commit.rb | |
parent | 58dcfe0e3d3bb7b12e3f7aa4aed49bd0cc97c912 (diff) | |
download | gitlab-ci-40830fee8bcdfd465fb87fada28ef049a080acf2.tar.gz |
better yaml validation
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r-- | app/models/commit.rb | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 1dc3e15..da755bc 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -93,9 +93,19 @@ class Commit < ActiveRecord::Base def create_builds return if skip_ci? - return unless config_processor.valid? - config_processor.builds_for_ref(ref, tag).each do |build_attrs| + unless config_processor.valid? + save_yaml_error(config_processor.errors.join(",")) and return + end + + begin + builds_for_ref = config_processor.builds_for_ref(ref, tag) + rescue Exception => e + logger.error e.message + "\n" + e.backtrace.join("\n") + save_yaml_error("Undefined yaml error") and return + end + + builds_for_ref.each do |build_attrs| builds.create!({ project: project, name: build_attrs[:name], @@ -121,9 +131,19 @@ class Commit < ActiveRecord::Base def create_deploy_builds return if skip_ci? - return unless config_processor.valid? - config_processor.deploy_builds_for_ref(ref, tag).each do |build_attrs| + unless config_processor.valid? + save_yaml_error(config_processor.errors.join(",")) and return + end + + begin + deploy_builds_for_ref = config_processor.deploy_builds_for_ref(ref, tag) + rescue Exception => e + logger.error e.message + "\n" + e.backtrace.join("\n") + save_yaml_error("Undefined yaml error") and return + end + + deploy_builds_for_ref.each do |build_attrs| builds.create!({ project: project, name: build_attrs[:name], @@ -135,6 +155,10 @@ class Commit < ActiveRecord::Base end def status + if yaml_errors.present? + return 'failed' + end + if success? 'success' elsif pending? @@ -207,4 +231,11 @@ class Commit < ActiveRecord::Base false end end + + private + + def save_yaml_error(error) + self.yaml_errors = error + save + end end |