From 4f1c63683175fa88ca41ba2180b68e266d7118e4 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 18 May 2016 17:01:42 -0500 Subject: [PATCH] Create pipeline objects with parameters --- app/controllers/projects/pipelines_controller.rb | 4 ++-- app/services/ci/create_pipeline_service.rb | 4 +--- app/views/projects/commit/_ci_commit.html.haml | 4 ++-- app/views/projects/pipelines/new.html.haml | 8 ++++---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 1282913d981..b36081205d8 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -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 diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb index b864807ec35..5bc0c31cb42 100644 --- a/app/services/ci/create_pipeline_service.rb +++ b/app/services/ci/create_pipeline_service.rb @@ -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') diff --git a/app/views/projects/commit/_ci_commit.html.haml b/app/views/projects/commit/_ci_commit.html.haml index df92a38db31..8228c067be0 100644 --- a/app/views/projects/commit/_ci_commit.html.haml +++ b/app/views/projects/commit/_ci_commit.html.haml @@ -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 diff --git a/app/views/projects/pipelines/new.html.haml b/app/views/projects/pipelines/new.html.haml index 1050b28b381..b97c9f5f3b6 100644 --- a/app/views/projects/pipelines/new.html.haml +++ b/app/views/projects/pipelines/new.html.haml @@ -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