Browse Source

构建流水线

pull/347/head
xxq250 2 years ago
parent
commit
eb5c2a6b8b
2 changed files with 14 additions and 14 deletions
  1. +13
    -13
      app/controllers/api/v1/projects/pipelines_controller.rb
  2. +1
    -1
      config/routes/api.rb

+ 13
- 13
app/controllers/api/v1/projects/pipelines_controller.rb View File

@@ -23,20 +23,20 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
end

def build_yaml
# pipeline = params[:pipeline]
# @name = params[:name]
# params_nodes = JSON.parse(pipeline)["nodes"].select { |node| !["on-push", "on-schedule"].include?(node["component_name"]) }
# on_nodes = JSON.parse(pipeline)["nodes"].select { |node| ["on-push", "on-schedule"].include?(node["component_name"]) }
# @on_nodes = build_nodes(on_nodes)
# @steps_nodes = build_nodes(params_nodes)
# yaml = ERB.new(File.read(File.join(Rails.root, "app/views/api/v1/projects/pipelines", "build_pipeline.yaml.erb"))).result(binding)
# # 删除空行内容
# @pipeline_yaml = yaml.gsub(/^\s*\n/, "")
@pipeline_yaml = build_test_yaml
if params[:pipeline].present?
pipeline = params[:pipeline]
@name = params[:name]
params_nodes = JSON.parse(pipeline)["nodes"].select { |node| !["on-push", "on-schedule"].include?(node["component_name"]) }
on_nodes = JSON.parse(pipeline)["nodes"].select { |node| ["on-push", "on-schedule"].include?(node["component_name"]) }
@on_nodes = build_nodes(on_nodes)
@steps_nodes = build_nodes(params_nodes)
yaml = ERB.new(File.read(File.join(Rails.root, "app/views/api/v1/projects/pipelines", "build_pipeline.yaml.erb"))).result(binding)
# # 删除空行内容
@pipeline_yaml = yaml.gsub(/^\s*\n/, "")
else
@pipeline_yaml = build_test_yaml
end
render plain: @pipeline_yaml
# respond_to do |format|
# format.text { render yaml: @pipeline_yaml }
# end
end

def update


+ 1
- 1
config/routes/api.rb View File

@@ -130,7 +130,7 @@ defaults format: :json do
end
end
resources :pipelines do
get :build_yaml, on: :collection
post :build_yaml, on: :collection
end
resources :pulls, module: 'pulls' do
resources :versions, only: [:index] do


Loading…
Cancel
Save