Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-06-02 13:39:15 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-06-03 12:34:36 +0300
commitaf2f56f8f742e00ddb298fadea763fd0fe7054f0 (patch)
treebfd61f51789718d11eac6f8b47d3e33539123d6c /app/services/ci/create_pipeline_service.rb
parent3f4ac2ff60c9d83ec65b19070e4d054e12e67dd2 (diff)
Refactor ci commit pipeline to prevent implicit saves
Diffstat (limited to 'app/services/ci/create_pipeline_service.rb')
-rw-r--r--app/services/ci/create_pipeline_service.rb24
1 files changed, 11 insertions, 13 deletions
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb
index 5bc0c31cb42..0336b767de5 100644
--- a/app/services/ci/create_pipeline_service.rb
+++ b/app/services/ci/create_pipeline_service.rb
@@ -8,7 +8,9 @@ module Ci
return pipeline
end
- unless commit
+ if commit
+ pipeline.sha = commit.id
+ else
pipeline.errors.add(:base, 'Commit not found')
return pipeline
end
@@ -18,22 +20,18 @@ 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')
+ return pipeline
+ end
- unless pipeline.config_processor
- pipeline.errors.add(:base, pipeline.yaml_errors || 'Missing .gitlab-ci.yml file')
- raise ActiveRecord::Rollback
- end
+ pipeline.save!
- pipeline.save!
- pipeline.create_builds(current_user)
- end
- rescue
- pipeline.errors.add(:base, 'The pipeline could not be created. Please try again.')
+ unless pipeline.create_builds(current_user)
+ pipeline.errors.add(:base, 'No builds for this pipeline.')
end
+ pipeline.update_state!
pipeline
end