构建流水线

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
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

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