diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-06-17 09:02:40 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-06-17 09:02:40 +0000 |
commit | 5498a723fbe6b9d91cd5352104f8953395983c50 (patch) | |
tree | 2974823288b678d12e9b69f37d24550e8c1ca45a /app/models/commit.rb | |
parent | 311d6ea22f4b221e0740eb3c56e271806b5cc57c (diff) | |
parent | 40830fee8bcdfd465fb87fada28ef049a080acf2 (diff) | |
download | gitlab-ci-5498a723fbe6b9d91cd5352104f8953395983c50.tar.gz |
Merge branch 'better_yaml_validation' into 'master'
Better yaml validation
See merge request !160
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 |