Create pipeline objects with parameters

This commit is contained in:
Kamil Trzcinski 2016-05-18 17:01:42 -05:00
parent ef60b8e168
commit 4f1c636831
4 changed files with 9 additions and 11 deletions

View File

@ -15,7 +15,7 @@ class Projects::PipelinesController < Projects::ApplicationController
end
def new
@pipeline = project.ci_commits.new
@pipeline = project.ci_commits.new(ref: @project.default_branch)
end
def create
@ -46,7 +46,7 @@ class Projects::PipelinesController < Projects::ApplicationController
private
def create_params
params.permit(:ref)
params.require(:pipeline).permit(:ref)
end
def pipeline

View File

@ -1,7 +1,7 @@
module Ci
class CreatePipelineService < BaseService
def execute
pipeline = project.ci_commits.new
pipeline = project.ci_commits.new(params)
unless ref_names.include?(params[:ref])
pipeline.errors.add(:base, 'Reference not found')
@ -21,8 +21,6 @@ module Ci
begin
Ci::Commit.transaction do
pipeline.sha = commit.id
pipeline.ref = params[:ref]
pipeline.before_sha = Gitlab::Git::BLANK_SHA
unless pipeline.config_processor
pipeline.errors.add(:base, pipeline.yaml_errors || 'Missing .gitlab-ci.yml file')

View File

@ -7,8 +7,8 @@
- if ci_commit.builds.running_or_pending.any?
= link_to "Cancel running", cancel_namespace_project_pipeline_path(@project.namespace, @project, ci_commit.id), data: { confirm: 'Are you sure?' }, class: 'btn btn-grouped btn-danger', method: :post
- if defined?(pipeline_details) && pipeline_details
.oneline
.oneline.clearfix
- if defined?(pipeline_details) && pipeline_details
Pipeline
= link_to "##{ci_commit.id}", namespace_project_pipeline_path(@project.namespace, @project, ci_commit.id), class: "monospace"
with

View File

@ -5,15 +5,15 @@
New Pipeline
%hr
= form_for @pipeline, url: namespace_project_pipelines_path(@project.namespace, @project), html: { id: "new-pipeline-form", class: "form-horizontal js-new-pipeline-form js-requires-input" } do
= form_for @pipeline, as: :pipeline, url: namespace_project_pipelines_path(@project.namespace, @project), html: { id: "new-pipeline-form", class: "form-horizontal js-new-pipeline-form js-requires-input" } do |f|
= form_errors(@pipeline)
.form-group
= label_tag :ref, 'Create for', class: 'control-label'
= f.label :ref, 'Create for', class: 'control-label'
.col-sm-10
= text_field_tag :ref, params[:ref] || @project.default_branch, required: true, tabindex: 2, class: 'form-control'
= f.text_field :ref, required: true, tabindex: 2, class: 'form-control'
.help-block Existing branch name, tag
.form-actions
= button_tag 'Create pipeline', class: 'btn btn-create', tabindex: 3
= f.submit 'Create pipeline', class: 'btn btn-create', tabindex: 3
= link_to 'Cancel', namespace_project_pipelines_path(@project.namespace, @project), class: 'btn btn-cancel'
:javascript