ab9a8643d8
* master: (538 commits) Fix broken URI joining for `teamcity_url` with suffixes Factorize duplicated code into a method in BambooService and update specs Fix broken URI joining for `bamboo_url` with suffixes Honor credentials on calling Bamboo CI trigger Update CHANGELOG Use Issue.visible_to_user in Notes.search to avoid query duplication Project members with guest role can't access confidential issues Allow users to create confidential issues in private projects Update CHANGELOG Remove deprecated issues_tracker and issues_tracker_id from project Schema doesn’t reflect the changes of the last 3 migrations Apply reviewer notes: update CHANGELOG, adjust code formatting Move issue rendering tests into separate contexts Move change description to proper release and fix typo Add more information into RSS fead for issues Revert CHANGELOG Also rename "find" in the specs Change to new Notes styleguide Add guide on changing a document's location Change logs.md location in README ... Conflicts: app/services/ci/create_builds_service.rb app/services/ci/create_pipeline_service.rb app/services/create_commit_builds_service.rb spec/models/ci/commit_spec.rb spec/services/ci/create_builds_service_spec.rb spec/services/create_commit_builds_service_spec.rb
48 lines
1.1 KiB
Ruby
48 lines
1.1 KiB
Ruby
module Ci
|
|
class CreatePipelineService < BaseService
|
|
def execute
|
|
pipeline = project.pipelines.new(params)
|
|
|
|
unless ref_names.include?(params[:ref])
|
|
pipeline.errors.add(:base, 'Reference not found')
|
|
return pipeline
|
|
end
|
|
|
|
if commit
|
|
pipeline.sha = commit.id
|
|
else
|
|
pipeline.errors.add(:base, 'Commit not found')
|
|
return pipeline
|
|
end
|
|
|
|
unless can?(current_user, :create_pipeline, project)
|
|
pipeline.errors.add(:base, 'Insufficient permissions to create a new pipeline')
|
|
return pipeline
|
|
end
|
|
|
|
unless pipeline.config_processor
|
|
pipeline.errors.add(:base, pipeline.yaml_errors || 'Missing .gitlab-ci.yml file')
|
|
return pipeline
|
|
end
|
|
|
|
pipeline.save!
|
|
|
|
unless pipeline.create_builds(current_user)
|
|
pipeline.errors.add(:base, 'No builds for this pipeline.')
|
|
end
|
|
|
|
pipeline.save
|
|
pipeline
|
|
end
|
|
|
|
private
|
|
|
|
def ref_names
|
|
@ref_names ||= project.repository.ref_names
|
|
end
|
|
|
|
def commit
|
|
@commit ||= project.commit(params[:ref])
|
|
end
|
|
end
|
|
end
|