Commit 4f1c6368 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Create pipeline objects with parameters

parent ef60b8e1
......@@ -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
......
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')
......
......@@ -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
.oneline.clearfix
- if defined?(pipeline_details) && pipeline_details
.oneline
Pipeline
= link_to "##{ci_commit.id}", namespace_project_pipeline_path(@project.namespace, @project, ci_commit.id), class: "monospace"
with
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment