challenge保存的时候向jenkins发送请求,生成pipeline片段
This commit is contained in:
parent
bd2cbd6793
commit
ba0f5976f0
|
@ -24,6 +24,7 @@ class ChallengesController < ApplicationController
|
|||
@challenge.position = challenge_count + 1
|
||||
@challenge.shixun = @shixun
|
||||
@challenge.user = User.current
|
||||
ActiveRecord::Base.transaction do
|
||||
if @challenge.save
|
||||
if params[:sample][:input].length > 0
|
||||
params[:sample][:input].each_with_index do |value, index|
|
||||
|
@ -42,6 +43,10 @@ class ChallengesController < ApplicationController
|
|||
ChallengeTag.create(:name => input, :challenge_id => @challenge.id)
|
||||
end
|
||||
end
|
||||
# 向jenkins端发送请求,构建pipeline片段
|
||||
params = {:shixunType => "#{@challenge.evaluation_way.to_i}", :filePath => "#{@challenge.path}", :step => "#{@challenge.position}"}
|
||||
uri = URI("#{jenkins_shixuns}/jenkins-exec/api/generateScriptPerChallenge")
|
||||
res = uri_exec uri, params
|
||||
respond_to do |format|
|
||||
format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: '创建成功!'}
|
||||
end
|
||||
|
@ -51,6 +56,7 @@ class ChallengesController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
# 顶部导航
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddScriptToChallenge < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :challenges, :pipeline_script, :text
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue