summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-06-01 12:52:28 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-06-01 12:54:58 +0200
commit41f41911bcab3679f0a0d7ac5a61ac0fb19ca5f3 (patch)
tree47fbd6c4cf1d90117d72c57b52793feb52c6ef26
parentba81c91255aac2d724ceb94e3eb91f912227e2eb (diff)
downloadgitlab-ce-refactor_config_processor_save.tar.gz
Remove save_yaml_error from config_processor and don't create Ci::Commit if no builds were createdrefactor_config_processor_save
-rw-r--r--app/models/ci/commit.rb10
-rw-r--r--app/services/ci/create_pipeline_service.rb25
-rw-r--r--app/services/ci/image_for_build_service.rb3
-rw-r--r--app/services/create_commit_builds_service.rb7
4 files changed, 19 insertions, 26 deletions
diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb
index 6675a3f5d53..86b819f2192 100644
--- a/app/models/ci/commit.rb
+++ b/app/models/ci/commit.rb
@@ -131,10 +131,10 @@ module Ci
@config_processor ||= begin
Ci::GitlabCiYamlProcessor.new(ci_yaml_file, project.path_with_namespace)
rescue Ci::GitlabCiYamlProcessor::ValidationError, Psych::SyntaxError => e
- save_yaml_error(e.message)
+ self.yaml_errors = e.message
nil
rescue
- save_yaml_error("Undefined error")
+ self.yaml_errors = "Undefined error"
nil
end
end
@@ -169,11 +169,5 @@ module Ci
self.duration = statuses.latest.duration
save
end
-
- def save_yaml_error(error)
- return if self.yaml_errors?
- self.yaml_errors = error
- update_state
- end
end
end
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb
index 5bc0c31cb42..cf7fc39cdfd 100644
--- a/app/services/ci/create_pipeline_service.rb
+++ b/app/services/ci/create_pipeline_service.rb
@@ -18,22 +18,19 @@ module Ci
return pipeline
end
- begin
- Ci::Commit.transaction do
- pipeline.sha = commit.id
-
- unless pipeline.config_processor
- pipeline.errors.add(:base, pipeline.yaml_errors || 'Missing .gitlab-ci.yml file')
- raise ActiveRecord::Rollback
- end
-
- pipeline.save!
- pipeline.create_builds(current_user)
- end
- rescue
- pipeline.errors.add(:base, 'The pipeline could not be created. Please try again.')
+ unless pipeline.config_processor
+ pipeline.errors.add(:base, pipeline.yaml_errors || 'Missing .gitlab-ci.yml file')
+ return pipeline
+ end
+
+ pipeline.sha = commit.id
+
+ unless pipeline.create_builds(current_user)
+ pipeline.errors.add(:base, 'No builds created')
+ return pipeline
end
+ pipeline.touch
pipeline
end
diff --git a/app/services/ci/image_for_build_service.rb b/app/services/ci/image_for_build_service.rb
index 3018f27ec05..054e90a3036 100644
--- a/app/services/ci/image_for_build_service.rb
+++ b/app/services/ci/image_for_build_service.rb
@@ -1,6 +1,9 @@
module Ci
class ImageForBuildService
def execute(project, opts)
+ # sha - commit sha
+ # ref - commit reference
+
sha = opts[:sha] || ref_sha(project, opts[:ref])
ci_commits = project.ci_commits.where(sha: sha)
diff --git a/app/services/create_commit_builds_service.rb b/app/services/create_commit_builds_service.rb
index 5b6fefe669e..952eabbcfce 100644
--- a/app/services/create_commit_builds_service.rb
+++ b/app/services/create_commit_builds_service.rb
@@ -25,13 +25,12 @@ class CreateCommitBuildsService
return false
end
- # Create a new ci_commit
- commit.save!
-
# Skip creating builds for commits that have [ci skip]
unless commit.skip_ci?
# Create builds for commit
- commit.create_builds(user)
+ unless commit.create_builds(user)
+ return false
+ end
end
commit.touch