构建流水线

This commit is contained in:
xxq250 2024-05-22 14:35:22 +08:00
parent 6f25498c29
commit eb5c2a6b8b
2 changed files with 14 additions and 14 deletions

View File

@ -23,20 +23,20 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
end end
def build_yaml def build_yaml
# pipeline = params[:pipeline] if params[:pipeline].present?
# @name = params[:name] pipeline = params[:pipeline]
# params_nodes = JSON.parse(pipeline)["nodes"].select { |node| !["on-push", "on-schedule"].include?(node["component_name"]) } @name = params[:name]
# on_nodes = JSON.parse(pipeline)["nodes"].select { |node| ["on-push", "on-schedule"].include?(node["component_name"]) } params_nodes = JSON.parse(pipeline)["nodes"].select { |node| !["on-push", "on-schedule"].include?(node["component_name"]) }
# @on_nodes = build_nodes(on_nodes) on_nodes = JSON.parse(pipeline)["nodes"].select { |node| ["on-push", "on-schedule"].include?(node["component_name"]) }
# @steps_nodes = build_nodes(params_nodes) @on_nodes = build_nodes(on_nodes)
# yaml = ERB.new(File.read(File.join(Rails.root, "app/views/api/v1/projects/pipelines", "build_pipeline.yaml.erb"))).result(binding) @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 = yaml.gsub(/^\s*\n/, "")
else
@pipeline_yaml = build_test_yaml @pipeline_yaml = build_test_yaml
end
render plain: @pipeline_yaml render plain: @pipeline_yaml
# respond_to do |format|
# format.text { render yaml: @pipeline_yaml }
# end
end end
def update def update

View File

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