challenge创建整理

This commit is contained in:
huang 2017-05-22 16:51:44 +08:00
parent 903525ded6
commit e0191f0934
1 changed files with 3 additions and 6 deletions

View File

@ -45,17 +45,14 @@ class ChallengesController < ApplicationController
jenkins_shixuns = Redmine::Configuration['jenkins_shixuns']
params = {:challengeStage => "#{@challenge.position}", :challengeType => "#{@challenge.evaluation_way.to_i}", :challengeProgramName => "#{@challenge.exec_path}", :trainingID => "#{@shixun.id}", :operationEnvironment => @shixun.language}
uri = URI("#{jenkins_shixuns}/jenkins-exec/game/generatePipelineScriptForChallenge")
if res['code'] == 0
res = uri_exec uri, {challengeInfo: params.to_json}
if res && res['code'] == 0
@challenge.update_attribute(:pipeline_script, res['msg'])
respond_to do |format|
format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun)}
end
else
logger.error("res['code'] is #{res['code']}, res['msg'] is #{res['msg']}")
# unless res['msg'].blank?
# test_msg = Base64.decode64(res['msg'])
# end
# logger.info("###############{test_msg}")
raise("脚本构建失败:本关执行文件名格式错误")
end
rescue Exception => e
@ -124,7 +121,7 @@ class ChallengesController < ApplicationController
params = {:challengeStage => "#{@challenge.position}", :challengeType => "#{@challenge.evaluation_way.to_i}", :challengeProgramName => "#{@challenge.exec_path}", :trainingID => "#{@shixun.id}", :operationEnvironment => @shixun.language}
uri = URI("#{jenkins_shixuns}/jenkins-exec/game/generatePipelineScriptForChallenge")
res = uri_exec uri, {challengeInfo: params.to_json}
if res['code'] == 0
if res && res['code'] == 0
@challenge.update_attribute(:pipeline_script, res['msg'])
else
logger.error("res['code'] is #{res['code']}, res['msg'] is #{res['code']}")