修复pipeline中的错误
This commit is contained in:
parent
84aec996b6
commit
99e03ae357
|
@ -1,7 +1,8 @@
|
|||
if (currentChallenge == CHALLENGESTAGE) {
|
||||
String compileCommand = COMPILECOMMAND
|
||||
String challengeProgramName = CHALLENGEPROGRAMNAME
|
||||
String executeCommand = EXECUTECOMMAND
|
||||
String sourceClassName = SOURCECLASSNAME
|
||||
buildJob(compileCommand:compileCommand,challengeProgramName:challengeProgramName, executeCommand:executeCommand, sourceClassName:sourceClassName)
|
||||
String compileCommand = 'COMPILECOMMAND'
|
||||
String challengeProgramName = 'CHALLENGEPROGRAMNAME'
|
||||
String executeCommand = 'EXECUTECOMMAND'
|
||||
String sourceClassName = 'SOURCECLASSNAME'
|
||||
trainingID = 'TRAININGID'
|
||||
buildJob(compileCommand:compileCommand,challengeProgramName:challengeProgramName, executeCommand:executeCommand, sourceClassName:sourceClassName, trainingID:trainingID)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
if (currentChallenge == CHALLENGESTAGE) {
|
||||
String compileCommand = COMPILECOMMAND
|
||||
String challengeProgramName = CHALLENGEPROGRAMNAME
|
||||
String executeCommand = EXECUTECOMMAND
|
||||
String sourceClassName = SOURCECLASSNAME
|
||||
buildJob(compileCommand:compileCommand,challengeProgramName:challengeProgramName, executeCommand:executeCommand, sourceClassName:sourceClassName)
|
||||
String compileCommand = 'COMPILECOMMAND'
|
||||
String challengeProgramName = 'CHALLENGEPROGRAMNAME'
|
||||
String executeCommand = 'EXECUTECOMMAND'
|
||||
String sourceClassName = 'SOURCECLASSNAME'
|
||||
trainingID = 'TRAININGID'
|
||||
buildJob(compileCommand:compileCommand,challengeProgramName:challengeProgramName, executeCommand:executeCommand, sourceClassName:sourceClassName, trainingID:trainingID)
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
if (currentChallenge == CHALLENGESTAGE) {
|
||||
String compileCommand = COMPILECOMMAND
|
||||
String challengeProgramName = CHALLENGEPROGRAMNAME
|
||||
String executeCommand = EXECUTECOMMAND
|
||||
String sourceClassName = SOURCECLASSNAME
|
||||
buildJob(compileCommand:compileCommand,challengeProgramName:challengeProgramName, executeCommand:executeCommand, sourceClassName:sourceClassName)
|
||||
String compileCommand = 'COMPILECOMMAND'
|
||||
String challengeProgramName = 'CHALLENGEPROGRAMNAME'
|
||||
String executeCommand = 'EXECUTECOMMAND'
|
||||
String sourceClassName = 'SOURCECLASSNAME'
|
||||
trainindID = 'TRAININGID'
|
||||
buildJob(compileCommand:compileCommand,challengeProgramName:challengeProgramName, executeCommand:executeCommand, sourceClassName:sourceClassName, trainindID:trainindID)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
if (currentChallenge == CHALLENGESTAGE) {
|
||||
|
||||
executeCommand = EXECUTECOMMAND
|
||||
sourceClassName = SOURCECLASSNAME
|
||||
trainindID = TRAININGID
|
||||
buildJob(trainingID:trainingID,challengeStage:currentChallenge,executeCommand:executeCommand,sourceClassName:sourceClassName)
|
||||
executeCommand = 'EXECUTECOMMAND'
|
||||
sourceClassName = 'SOURCECLASSNAME'
|
||||
trainindID = 'TRAININGID'
|
||||
buildJob(trainingID:trainingID,challengeStage:currentChallenge,executeCommand:executeCommand,sourceClassName:sourceClassName, trainindID:trainindID)
|
||||
}
|
|
@ -1,151 +1,171 @@
|
|||
{
|
||||
node('PODLABEL') {
|
||||
mysql_isOnline=false
|
||||
container('mysql') {
|
||||
//循环测试mysql是否上线
|
||||
for(int j=0;j<10;j++)
|
||||
{
|
||||
try{
|
||||
sh 'mysql -uroot -p123123 -e "show databases"'
|
||||
mysql_isOnline=true
|
||||
break;
|
||||
}catch(err){
|
||||
sleep 1
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
container('MAINCONTAINER') {
|
||||
def currentChallenge = Integer.parseInt(instanceChallenge)
|
||||
// 解决stage 0 401没有权限的问题
|
||||
if (currentChallenge == 0) {
|
||||
boolean flag = false;
|
||||
for(int i=0;i<5;i++){
|
||||
catchError {
|
||||
println(i + "times")
|
||||
Thread.sleep(100)
|
||||
git url: instanceGitURL
|
||||
flag = true;
|
||||
}
|
||||
if(flag == true) {
|
||||
currentBuild.result = 'SUCCESS';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
git url: instanceGitURL
|
||||
node('PODLABEL')
|
||||
{
|
||||
mysql_isOnline=false
|
||||
container('mysql')
|
||||
{
|
||||
//循环测试mysql是否上线
|
||||
for(int j=0;j<10;j++)
|
||||
{
|
||||
try
|
||||
{
|
||||
sh 'mysql -uroot -p123123 -e "show databases"'
|
||||
mysql_isOnline=true
|
||||
break;
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
sleep 1
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
container('MAINCONTAINER')
|
||||
{
|
||||
def currentChallenge = Integer.parseInt(instanceChallenge)
|
||||
// 解决stage 0 401没有权限的问题
|
||||
if (currentChallenge == 0)
|
||||
{
|
||||
boolean flag = false;
|
||||
for(int i=0;i<5;i++)
|
||||
{
|
||||
catchError
|
||||
{
|
||||
println(i + "times")
|
||||
Thread.sleep(100)
|
||||
git url: instanceGitURL
|
||||
flag = true;
|
||||
}
|
||||
if(flag == true)
|
||||
{
|
||||
currentBuild.result = 'SUCCESS';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CHALLENGEPIPELINES
|
||||
}
|
||||
git url: instanceGitURL
|
||||
|
||||
CHALLENGEPIPELINES
|
||||
}
|
||||
}
|
||||
}
|
||||
def buildJob(def arg)
|
||||
{
|
||||
compileResult = ''
|
||||
try
|
||||
{
|
||||
// 编译程序
|
||||
sh script: arg.compileCommand + ' ' + arg.challengeProgramName + '> compile_result_' + arg.challengeStage + '.out 2>&1'
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
//resubmit是以字符串的形式传进来的
|
||||
//重复构建时需要删除之前构建的成功的class并catch掉class文件不存在的异常
|
||||
|
||||
catchError
|
||||
{
|
||||
sh 'rm target/step' + arg.challengeStage + '/*.class'
|
||||
}
|
||||
}
|
||||
|
||||
//获取编译结果
|
||||
compileResult = readFile ('compile_result_' + arg.challengeStage + '.out')
|
||||
|
||||
// 如果编译通过
|
||||
if (compileResult.trim() == '')
|
||||
{
|
||||
compileResult = 'compile successfully'
|
||||
}
|
||||
|
||||
|
||||
StringBuilder input = new StringBuilder('[')
|
||||
StringBuilder output = new StringBuilder('[')
|
||||
StringBuilder expectedOut = new StringBuilder('[')
|
||||
StringBuilder isPublic = new StringBuilder('[')
|
||||
//得到文件夹下的文件总数
|
||||
def fileNumsStr = sh script: 'cd ../testCases/' + arg.trainingID + '/' + arg.challengeStage + '&& ls -l |grep "^-"|wc -l', returnStdout: true
|
||||
def fileNums = Integer.parseInt(fileNumsStr.trim())
|
||||
for (int i = 1; i <= fileNums/3; i++)
|
||||
{
|
||||
// 读取输入和预期输出
|
||||
//由于文件的名字的命名是有规律的,所以可以直接以序号来拼接成文件名
|
||||
def inI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.in'
|
||||
def expectedOutI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.out'
|
||||
def isPublicI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.isPublic'
|
||||
//取出文件执行得到结果,然后和预期输出比较就可以判断正误
|
||||
// 从in.txt读入,程序运行输出重定向到out.txt
|
||||
|
||||
|
||||
if(mysql_isOnline)
|
||||
{
|
||||
|
||||
catchError
|
||||
{
|
||||
|
||||
sh script: arg.executeCommand + ' ' + arg.sourceClassName + ' < ../testCases/' + arg.trainingID +'/' + arg.challengeStage + '/' + i + '.in > actual_result_' + arg.challengeStage + '_' + i + '.out 2>&1 '
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sh script: 'echo mysql 服务启动失败 > actual_result_' + arg.challengeStage + '_' + i + '.out'
|
||||
}
|
||||
|
||||
def outI = readFile 'actual_result_' + arg.challengeStage + '_' + i + '.out'
|
||||
|
||||
// 拼接成json格式
|
||||
input.append("\"" + base64Encode(inI) + "\",");
|
||||
output.append("\"" + base64Encode(outI) + "\",");
|
||||
expectedOut.append("\"" + base64Encode(expectedOutI) + "\",");
|
||||
isPublic.append("\"" + isPublicI + "\",");
|
||||
|
||||
}
|
||||
|
||||
input = input.deleteCharAt(input.length() - 1);
|
||||
input = input.append("]");
|
||||
|
||||
output = output.deleteCharAt(output.length() - 1);
|
||||
output = output.append("]");
|
||||
|
||||
expectedOut = expectedOut.deleteCharAt(expectedOut.length() - 1);
|
||||
expectedOut = expectedOut.append("]");
|
||||
|
||||
isPublic = isPublic.deleteCharAt(isPublic.length() - 1);
|
||||
isPublic = isPublic.append("]");
|
||||
// 由中间层判断结果之后发送给BDWeb
|
||||
postGameInstanceResultToBDWeb(compileResult: base64Encode(compileResult), out: output, in:input, expectedOut:expectedOut , isPublic:isPublic)
|
||||
|
||||
}
|
||||
// 传送运行结果到BDWeb
|
||||
def postGameInstanceResultToBDWeb(def arg){
|
||||
def postGameInstanceResultToBDWeb(def arg)
|
||||
{
|
||||
def s = 'compileResult=' + arg.compileResult + '&out=' + arg.out +
|
||||
'&in=' + arg.in + '&expectedOut=' + arg.expectedOut + '&isPublic=' + arg.isPublic
|
||||
def response = httpRequest acceptType: 'APPLICATION_JSON_UTF8', consoleLogResponseBody: true, contentType: 'APPLICATION_FORM',
|
||||
httpMode: 'POST', requestBody: s, url: BRIDGE_URL+"/jenkins-exec/pipeline/postTrainingGameInstanceResultToBDWeb?buildID=${buildID}&reSubmit=${resubmit}"
|
||||
|
||||
if (response.status==299){
|
||||
if (response.status==299)
|
||||
{
|
||||
error response.content
|
||||
}
|
||||
}
|
||||
// 传送错误结果到BDWeb
|
||||
def postErrorToBDWeb(def arg){
|
||||
def postErrorToBDWeb(def arg)
|
||||
{
|
||||
def s = 'errType=' + arg.errType + '&value=' + arg.value
|
||||
def response = httpRequest acceptType: 'APPLICATION_JSON_UTF8', consoleLogResponseBody: true, contentType: 'APPLICATION_FORM',
|
||||
httpMode: 'POST', requestBody: s, url: "http://123.59.135.74:9201/jenkins-exec/pipeline/postErrToBDWeb?buildID=${buildID}"
|
||||
|
||||
if (response.status==299){
|
||||
if (response.status==299)
|
||||
{
|
||||
error response.content
|
||||
}
|
||||
}
|
||||
|
||||
def base64Encode(arg) {
|
||||
def base64Encode(arg)
|
||||
{
|
||||
return arg.bytes.encodeBase64().toString()
|
||||
}
|
||||
|
||||
def bildJob(def arg)
|
||||
{
|
||||
if (currentChallenge == CHALLENGESTAGE) {
|
||||
|
||||
compileResult = ''
|
||||
try
|
||||
{
|
||||
// 编译程序
|
||||
sh script: arg.compileCommand + ' ' + arg.challengeProgramName + '> compile_result_' + arg.challengeStage + '.out 2>&1'
|
||||
} catch(err)
|
||||
{
|
||||
//resubmit是以字符串的形式传进来的
|
||||
//重复构建时需要删除之前构建的成功的class并catch掉class文件不存在的异常
|
||||
|
||||
catchError{
|
||||
sh 'rm target/step' + CHALLENGESTAGE + '/*.class'
|
||||
}
|
||||
}
|
||||
|
||||
//获取编译结果
|
||||
compileResult = readFile ('compile_result_' + CHALLENGESTAGE + '.out')
|
||||
|
||||
// 如果编译通过
|
||||
if (compileResult.trim() == '') {
|
||||
compileResult = 'compile successfully'
|
||||
}
|
||||
|
||||
|
||||
StringBuilder input = new StringBuilder('[')
|
||||
StringBuilder output = new StringBuilder('[')
|
||||
StringBuilder expectedOut = new StringBuilder('[')
|
||||
StringBuilder isPublic = new StringBuilder('[')
|
||||
//得到文件夹下的文件总数
|
||||
def fileNumsStr = sh script: 'cd ../testCases/' + arg.trainingID + '/' + arg.challengeStage + '&& ls -l |grep "^-"|wc -l', returnStdout: true
|
||||
def fileNums = Integer.parseInt(fileNumsStr.trim())
|
||||
for (int i = 1; i <= fileNums/3; i++) {
|
||||
// 读取输入和预期输出
|
||||
//由于文件的名字的命名是有规律的,所以可以直接以序号来拼接成文件名
|
||||
def inI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.in'
|
||||
def expectedOutI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.out'
|
||||
def isPublicI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.isPublic'
|
||||
//取出文件执行得到结果,然后和预期输出比较就可以判断正误
|
||||
// 从in.txt读入,程序运行输出重定向到out.txt
|
||||
|
||||
|
||||
if(mysql_isOnline){
|
||||
|
||||
catchError
|
||||
{
|
||||
|
||||
sh script: arg.executeCommand + ' ' + arg.sourceClassName + ' < ../testCases/' + arg.trainingID +'/' + arg.challengeStage + '/' + i + '.in > actual_result_' + arg.challengeStage + '_' + i + '.out 2>&1 '
|
||||
|
||||
}
|
||||
}else{
|
||||
sh script: 'echo mysql 服务启动失败 > actual_result_' + arg.challengeStage + '_' + i + '.out'
|
||||
}
|
||||
|
||||
def outI = readFile 'actual_result_' + arg.challengeStage + '_' + i + '.out'
|
||||
|
||||
// 拼接成json格式
|
||||
input.append("\"" + base64Encode(inI) + "\",");
|
||||
output.append("\"" + base64Encode(outI) + "\",");
|
||||
expectedOut.append("\"" + base64Encode(expectedOutI) + "\",");
|
||||
isPublic.append("\"" + isPublicI + "\",");
|
||||
|
||||
}
|
||||
|
||||
input = input.deleteCharAt(input.length() - 1);
|
||||
input = input.append("]");
|
||||
|
||||
output = output.deleteCharAt(output.length() - 1);
|
||||
output = output.append("]");
|
||||
|
||||
expectedOut = expectedOut.deleteCharAt(expectedOut.length() - 1);
|
||||
expectedOut = expectedOut.append("]");
|
||||
|
||||
isPublic = isPublic.deleteCharAt(isPublic.length() - 1);
|
||||
isPublic = isPublic.append("]");
|
||||
// 由中间层判断结果之后发送给BDWeb
|
||||
postGameInstanceResultToBDWeb(compileResult: base64Encode(compileResult), out: output, in:input, expectedOut:expectedOut , isPublic:isPublic)
|
||||
|
||||
}
|
|
@ -1,129 +1,144 @@
|
|||
{
|
||||
node('PODLABEL') {
|
||||
container('MAINCONTAINER') {
|
||||
def currentChallenge = Integer.parseInt(instanceChallenge)
|
||||
// 解决stage 0 401没有权限的问题
|
||||
if (currentChallenge == 0) {
|
||||
boolean flag = false;
|
||||
for(int i=0;i<5;i++){
|
||||
catchError {
|
||||
println(i + "times")
|
||||
Thread.sleep(100)
|
||||
git url: instanceGitURL
|
||||
flag = true;
|
||||
}
|
||||
if(flag == true) {
|
||||
currentBuild.result = 'SUCCESS';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
git url: instanceGitURL
|
||||
node('PODLABEL')
|
||||
{
|
||||
container('MAINCONTAINER')
|
||||
{
|
||||
def currentChallenge = Integer.parseInt(instanceChallenge)
|
||||
// 解决stage 0 401没有权限的问题
|
||||
if (currentChallenge == 0)
|
||||
{
|
||||
boolean flag = false;
|
||||
for(int i=0;i<5;i++)
|
||||
{
|
||||
catchError
|
||||
{
|
||||
println(i + "times")
|
||||
Thread.sleep(100)
|
||||
git url: instanceGitURL
|
||||
flag = true;
|
||||
}
|
||||
if(flag == true)
|
||||
{
|
||||
currentBuild.result = 'SUCCESS';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CHALLENGEPIPELINES
|
||||
git url: instanceGitURL
|
||||
|
||||
CHALLENGEPIPELINES
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 传送运行结果到BDWeb
|
||||
def postGameInstanceResultToBDWeb(def arg){
|
||||
def s = 'compileResult=' + arg.compileResult + '&out=' + arg.out +
|
||||
'&in=' + arg.in + '&expectedOut=' + arg.expectedOut + '&isPublic=' + arg.isPublic
|
||||
def response = httpRequest acceptType: 'APPLICATION_JSON_UTF8', consoleLogResponseBody: true, contentType: 'APPLICATION_FORM',
|
||||
//httpMode: 'POST', requestBody: s, url: "http://123.59.135.74:9201/jenkins-exec/pipeline/postTrainingGameInstanceResultToBDWeb?buildID=${buildID}&reSubmit=${resubmit}"
|
||||
httpMode: 'POST', requestBody: s, url: BRIDGE_URL+"/jenkins-exec/pipeline/postTrainingGameInstanceResultToBDWeb?buildID=${buildID}&reSubmit=${resubmit}"
|
||||
|
||||
if (response.status==299){
|
||||
error response.content
|
||||
}
|
||||
}
|
||||
// 传送错误结果到BDWeb
|
||||
def postErrorToBDWeb(def arg){
|
||||
def s = 'errType=' + arg.errType + '&value=' + arg.value
|
||||
def response = httpRequest acceptType: 'APPLICATION_JSON_UTF8', consoleLogResponseBody: true, contentType: 'APPLICATION_FORM',
|
||||
httpMode: 'POST', requestBody: s, url: "http://123.59.135.74:9201/jenkins-exec/pipeline/postErrToBDWeb?buildID=${buildID}"
|
||||
|
||||
|
||||
if (response.status==299){
|
||||
error response.content
|
||||
}
|
||||
}
|
||||
|
||||
def base64Encode(arg) {
|
||||
return arg.bytes.encodeBase64().toString()
|
||||
}
|
||||
def bildJob(def arg)
|
||||
def buildJob(def arg)
|
||||
{
|
||||
compileResult = ''
|
||||
try
|
||||
{
|
||||
// 编译程序
|
||||
sh script: arg.compileCommand + ' ' + arg.challengeProgramName + '> compile_result_' + arg.challengeStage + '.out 2>&1'
|
||||
} catch(err)
|
||||
{
|
||||
//resubmit是以字符串的形式传进来的
|
||||
//重复构建时需要删除之前构建的成功的class并catch掉class文件不存在的异常
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
//resubmit是以字符串的形式传进来的
|
||||
//重复构建时需要删除之前构建的成功的class并catch掉class文件不存在的异常
|
||||
|
||||
catchError{
|
||||
sh 'rm target/step' + CHALLENGESTAGE + '/*.class'
|
||||
}
|
||||
}
|
||||
catchError
|
||||
{
|
||||
sh 'rm target/step' + arg.challengeStage + '/*.class'
|
||||
}
|
||||
}
|
||||
|
||||
//获取编译结果
|
||||
compileResult = readFile ('compile_result_' + CHALLENGESTAGE + '.out')
|
||||
//获取编译结果
|
||||
compileResult = readFile ('compile_result_' + arg.challengeStage + '.out')
|
||||
|
||||
// 如果编译通过
|
||||
if (compileResult.trim() == '') {
|
||||
compileResult = 'compile successfully'
|
||||
}
|
||||
// 如果编译通过
|
||||
if (compileResult.trim() == '')
|
||||
{
|
||||
compileResult = 'compile successfully'
|
||||
}
|
||||
|
||||
|
||||
StringBuilder input = new StringBuilder('[')
|
||||
StringBuilder output = new StringBuilder('[')
|
||||
StringBuilder expectedOut = new StringBuilder('[')
|
||||
StringBuilder isPublic = new StringBuilder('[')
|
||||
//得到文件夹下的文件总数
|
||||
def fileNumsStr = sh script: 'cd ../testCases/' + arg.trainingID + '/' + arg.challengeStage + '&& ls -l |grep "^-"|wc -l', returnStdout: true
|
||||
def fileNums = Integer.parseInt(fileNumsStr.trim())
|
||||
for (int i = 1; i <= fileNums/3; i++) {
|
||||
// 读取输入和预期输出
|
||||
//由于文件的名字的命名是有规律的,所以可以直接以序号来拼接成文件名
|
||||
def inI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.in'
|
||||
def expectedOutI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.out'
|
||||
def isPublicI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.isPublic'
|
||||
//取出文件执行得到结果,然后和预期输出比较就可以判断正误
|
||||
// 从in.txt读入,程序运行输出重定向到out.txt
|
||||
StringBuilder input = new StringBuilder('[')
|
||||
StringBuilder output = new StringBuilder('[')
|
||||
StringBuilder expectedOut = new StringBuilder('[')
|
||||
StringBuilder isPublic = new StringBuilder('[')
|
||||
//得到文件夹下的文件总数
|
||||
def fileNumsStr = sh script: 'cd ../testCases/' + arg.trainingID + '/' + arg.challengeStage + '&& ls -l |grep "^-"|wc -l', returnStdout: true
|
||||
def fileNums = Integer.parseInt(fileNumsStr.trim())
|
||||
for (int i = 1; i <= fileNums/3; i++)
|
||||
{
|
||||
// 读取输入和预期输出
|
||||
//由于文件的名字的命名是有规律的,所以可以直接以序号来拼接成文件名
|
||||
def inI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.in'
|
||||
def expectedOutI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.out'
|
||||
def isPublicI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.isPublic'
|
||||
//取出文件执行得到结果,然后和预期输出比较就可以判断正误
|
||||
// 从in.txt读入,程序运行输出重定向到out.txt
|
||||
|
||||
catchError
|
||||
{
|
||||
|
||||
sh script: arg.executeCommand + ' ' + arg.sourceClassName + ' < ../testCases/' + arg.trainingID +'/' + arg.challengeStage + '/' + i + '.in > actual_result_' + arg.challengeStage + '_' + i + '.out 2>&1 '
|
||||
}
|
||||
catchError
|
||||
{
|
||||
sh script: arg.executeCommand + ' ' + arg.sourceClassName + ' < ../testCases/' + arg.trainingID +'/' + arg.challengeStage + '/' + i + '.in > actual_result_' + arg.challengeStage + '_' + i + '.out 2>&1 '
|
||||
}
|
||||
|
||||
|
||||
|
||||
def outI = readFile 'actual_result_' + arg.challengeStage + '_' + i + '.out'
|
||||
def outI = readFile 'actual_result_' + arg.challengeStage + '_' + i + '.out'
|
||||
|
||||
// 拼接成json格式
|
||||
input.append("\"" + base64Encode(inI) + "\",");
|
||||
output.append("\"" + base64Encode(outI) + "\",");
|
||||
expectedOut.append("\"" + base64Encode(expectedOutI) + "\",");
|
||||
isPublic.append("\"" + isPublicI + "\",");
|
||||
|
||||
}
|
||||
|
||||
input = input.deleteCharAt(input.length() - 1);
|
||||
input = input.append("]");
|
||||
|
||||
output = output.deleteCharAt(output.length() - 1);
|
||||
output = output.append("]");
|
||||
|
||||
expectedOut = expectedOut.deleteCharAt(expectedOut.length() - 1);
|
||||
expectedOut = expectedOut.append("]");
|
||||
|
||||
isPublic = isPublic.deleteCharAt(isPublic.length() - 1);
|
||||
isPublic = isPublic.append("]");
|
||||
// 由中间层判断结果之后发送给BDWeb
|
||||
postGameInstanceResultToBDWeb(compileResult: base64Encode(compileResult), out: output, in:input, expectedOut:expectedOut , isPublic:isPublic)
|
||||
// 拼接成json格式
|
||||
input.append("\"" + base64Encode(inI) + "\",");
|
||||
output.append("\"" + base64Encode(outI) + "\",");
|
||||
expectedOut.append("\"" + base64Encode(expectedOutI) + "\",");
|
||||
isPublic.append("\"" + isPublicI + "\",");
|
||||
|
||||
}
|
||||
|
||||
input = input.deleteCharAt(input.length() - 1);
|
||||
input = input.append("]");
|
||||
|
||||
output = output.deleteCharAt(output.length() - 1);
|
||||
output = output.append("]");
|
||||
|
||||
expectedOut = expectedOut.deleteCharAt(expectedOut.length() - 1);
|
||||
expectedOut = expectedOut.append("]");
|
||||
|
||||
isPublic = isPublic.deleteCharAt(isPublic.length() - 1);
|
||||
isPublic = isPublic.append("]");
|
||||
// 由中间层判断结果之后发送给BDWeb
|
||||
postGameInstanceResultToBDWeb(compileResult: base64Encode(compileResult), out: output, in:input, expectedOut:expectedOut , isPublic:isPublic)
|
||||
|
||||
}
|
||||
// 传送运行结果到BDWeb
|
||||
def postGameInstanceResultToBDWeb(def arg)
|
||||
{
|
||||
def s = 'compileResult=' + arg.compileResult + '&out=' + arg.out +
|
||||
'&in=' + arg.in + '&expectedOut=' + arg.expectedOut + '&isPublic=' + arg.isPublic
|
||||
def response = httpRequest acceptType: 'APPLICATION_JSON_UTF8', consoleLogResponseBody: true, contentType: 'APPLICATION_FORM',
|
||||
//httpMode: 'POST', requestBody: s, url: "http://123.59.135.74:9201/jenkins-exec/pipeline/postTrainingGameInstanceResultToBDWeb?buildID=${buildID}&reSubmit=${resubmit}"
|
||||
httpMode: 'POST', requestBody: s, url: BRIDGE_URL+"/jenkins-exec/pipeline/postTrainingGameInstanceResultToBDWeb?buildID=${buildID}&reSubmit=${resubmit}"
|
||||
|
||||
if (response.status==299)
|
||||
{
|
||||
error response.content
|
||||
}
|
||||
}
|
||||
// 传送错误结果到BDWeb
|
||||
def postErrorToBDWeb(def arg)
|
||||
{
|
||||
def s = 'errType=' + arg.errType + '&value=' + arg.value
|
||||
def response = httpRequest acceptType: 'APPLICATION_JSON_UTF8', consoleLogResponseBody: true, contentType: 'APPLICATION_FORM',
|
||||
httpMode: 'POST', requestBody: s, url: "http://123.59.135.74:9201/jenkins-exec/pipeline/postErrToBDWeb?buildID=${buildID}"
|
||||
|
||||
|
||||
if (response.status==299)
|
||||
{
|
||||
error response.content
|
||||
}
|
||||
}
|
||||
|
||||
def base64Encode(arg)
|
||||
{
|
||||
return arg.bytes.encodeBase64().toString()
|
||||
}
|
|
@ -1,40 +1,34 @@
|
|||
{
|
||||
node('PODLABEL') {
|
||||
container('MAINCONTAINER') {
|
||||
def currentChallenge = Integer.parseInt(instanceChallenge)
|
||||
// 解决stage 0 401没有权限的问题
|
||||
if (currentChallenge == 0) {
|
||||
boolean flag = false;
|
||||
for(int i=0;i<5;i++){
|
||||
catchError {
|
||||
println(i + "times")
|
||||
Thread.sleep(100)
|
||||
git url: instanceGitURL
|
||||
flag = true;
|
||||
}
|
||||
if(flag == true) {
|
||||
currentBuild.result = 'SUCCESS';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
git url: instanceGitURL
|
||||
trainingID = TRAININGID
|
||||
CHALLENGEPIPELINES
|
||||
}
|
||||
}
|
||||
}
|
||||
// 传送运行结果到BDWeb
|
||||
def postGameInstanceResultToBDWeb(def arg){
|
||||
def s = 'compileResult=' + arg.compileResult + '&out=' + arg.out +
|
||||
'&in=' + arg.in + '&expectedOut=' + arg.expectedOut + '&isPublic=' + arg.isPublic
|
||||
def response = httpRequest acceptType: 'APPLICATION_JSON_UTF8', consoleLogResponseBody: true, contentType: 'APPLICATION_FORM',
|
||||
//httpMode: 'POST', requestBody: s, url: "http://123.59.135.74:9201/jenkins-exec/pipeline/postTrainingGameInstanceResultToBDWeb?buildID=${buildID}&reSubmit=${resubmit}"
|
||||
httpMode: 'POST', requestBody: s, url: BRIDGE_URL+"/jenkins-exec/pipeline/postTrainingGameInstanceResultToBDWeb?buildID=${buildID}&reSubmit=${resubmit}"
|
||||
|
||||
if (response.status==299){
|
||||
error response.content
|
||||
node('PODLABEL')
|
||||
{
|
||||
container('MAINCONTAINER')
|
||||
{
|
||||
def currentChallenge = Integer.parseInt(instanceChallenge)
|
||||
// 解决stage 0 401没有权限的问题
|
||||
if (currentChallenge == 0)
|
||||
{
|
||||
boolean flag = false;
|
||||
for(int i=0;i<5;i++)
|
||||
{
|
||||
catchError
|
||||
{
|
||||
println(i + "times")
|
||||
Thread.sleep(100)
|
||||
git url: instanceGitURL
|
||||
flag = true;
|
||||
}
|
||||
if(flag == true)
|
||||
{
|
||||
currentBuild.result = 'SUCCESS';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
git url: instanceGitURL
|
||||
trainingID = TRAININGID
|
||||
CHALLENGEPIPELINES
|
||||
}
|
||||
}
|
||||
}
|
||||
def buildJob(def arg)
|
||||
|
@ -48,7 +42,8 @@ def buildJob(def arg)
|
|||
//def fileNumsStr = sh script: 'cd ../testCases/' + arg.trainingID + '/' + arg.challengeStage && ls -l |grep "^-"|wc -l', returnStdout: true
|
||||
def fileNumsStr = sh script: 'cd ../testCases/' + arg.trainingID + '/'+ arg.challengeStage + ' && ls -l |grep "^-"|wc -l', returnStdout: true
|
||||
def fileNums = Integer.parseInt(fileNumsStr.trim())
|
||||
for (int i = 1; i <= fileNums/3; i++) {
|
||||
for (int i = 1; i <= fileNums/3; i++)
|
||||
{
|
||||
// 读取输入和预期输出
|
||||
//由于文件的名字的命名是有规律的,所以可以直接以序号来拼接成文件名
|
||||
def inI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.in'
|
||||
|
@ -66,13 +61,13 @@ def buildJob(def arg)
|
|||
}
|
||||
|
||||
|
||||
def outI = readFile 'actual_result_' + arg.challengeStage + '_' + i + '.out'
|
||||
def outI = readFile 'actual_result_' + arg.challengeStage + '_' + i + '.out'
|
||||
|
||||
// 拼接成json格式
|
||||
input.append("\"" + base64Encode(inI) + "\",");
|
||||
output.append("\"" + base64Encode(outI) + "\",");
|
||||
expectedOut.append("\"" + base64Encode(expectedOutI) + "\",");
|
||||
isPublic.append("\"" + isPublicI + "\",");
|
||||
// 拼接成json格式
|
||||
input.append("\"" + base64Encode(inI) + "\",");
|
||||
output.append("\"" + base64Encode(outI) + "\",");
|
||||
expectedOut.append("\"" + base64Encode(expectedOutI) + "\",");
|
||||
isPublic.append("\"" + isPublicI + "\",");
|
||||
|
||||
}
|
||||
|
||||
|
@ -91,18 +86,36 @@ def buildJob(def arg)
|
|||
postGameInstanceResultToBDWeb(compileResult: base64Encode(compileResult), out: output, in:input, expectedOut:expectedOut , isPublic:isPublic)
|
||||
|
||||
}
|
||||
// 传送运行结果到BDWeb
|
||||
def postGameInstanceResultToBDWeb(def arg)
|
||||
{
|
||||
def s = 'compileResult=' + arg.compileResult + '&out=' + arg.out +
|
||||
'&in=' + arg.in + '&expectedOut=' + arg.expectedOut + '&isPublic=' + arg.isPublic
|
||||
def response = httpRequest acceptType: 'APPLICATION_JSON_UTF8', consoleLogResponseBody: true, contentType: 'APPLICATION_FORM',
|
||||
//httpMode: 'POST', requestBody: s, url: "http://123.59.135.74:9201/jenkins-exec/pipeline/postTrainingGameInstanceResultToBDWeb?buildID=${buildID}&reSubmit=${resubmit}"
|
||||
httpMode: 'POST', requestBody: s, url: BRIDGE_URL+"/jenkins-exec/pipeline/postTrainingGameInstanceResultToBDWeb?buildID=${buildID}&reSubmit=${resubmit}"
|
||||
|
||||
if (response.status==299)
|
||||
{
|
||||
error response.content
|
||||
}
|
||||
}
|
||||
|
||||
// 传送错误结果到BDWeb
|
||||
def postErrorToBDWeb(def arg){
|
||||
def postErrorToBDWeb(def arg)
|
||||
{
|
||||
def s = 'errType=' + arg.errType + '&value=' + arg.value
|
||||
def response = httpRequest acceptType: 'APPLICATION_JSON_UTF8', consoleLogResponseBody: true, contentType: 'APPLICATION_FORM',
|
||||
httpMode: 'POST', requestBody: s, url: "http://123.59.135.74:9201/jenkins-exec/pipeline/postErrToBDWeb?buildID=${buildID}"
|
||||
|
||||
|
||||
if (response.status==299){
|
||||
if (response.status==299)
|
||||
{
|
||||
error response.content
|
||||
}
|
||||
}
|
||||
|
||||
def base64Encode(arg) {
|
||||
def base64Encode(arg)
|
||||
{
|
||||
return arg.bytes.encodeBase64().toString()
|
||||
}
|
|
@ -25,6 +25,83 @@ node('PODLABEL') {
|
|||
}
|
||||
}
|
||||
}
|
||||
def buildJob(def arg)
|
||||
{
|
||||
//生成编译文件路径,c++编译多文件可以使用g++ /*.cpp这种形式把所有的cpp全部编译
|
||||
compileFile = new StringBuilder(arg.challengeProgramName);
|
||||
lastPositon = compileFile.lastIndexOf('/');
|
||||
compileFile = compileFile.substring(0,lastPositon+1) + '*.cpp';
|
||||
compileResult = ''
|
||||
try
|
||||
{
|
||||
// 编译程序
|
||||
sh script: arg.compileCommand + ' ' + compileFile + ' -o executeFile.out > compile_result_' + arg.challengeStage + '.out 2>&1'
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
//resubmit是以字符串的形式传进来的
|
||||
//重复构建时需要删除之前构建的成功的class并catch掉class文件不存在的异常
|
||||
catchError{
|
||||
sh 'rm executeFile.out'
|
||||
}
|
||||
}
|
||||
|
||||
//获取编译结果
|
||||
compileResult = readFile ('compile_result_' + arg.challengeStage + '.out')
|
||||
|
||||
// 如果编译通过
|
||||
if (compileResult.trim() == '')
|
||||
{
|
||||
compileResult = 'compile successfully'
|
||||
}
|
||||
|
||||
|
||||
StringBuilder input = new StringBuilder('[')
|
||||
StringBuilder output = new StringBuilder('[')
|
||||
StringBuilder expectedOut = new StringBuilder('[')
|
||||
StringBuilder isPublic = new StringBuilder('[')
|
||||
//得到文件夹下的文件总数
|
||||
def fileNumsStr = sh script: 'cd ../testCases/' + arg.trainingID + '/' + arg.challengeStage + ' && ls -l |grep "^-"|wc -l', returnStdout: true
|
||||
def fileNums = Integer.parseInt(fileNumsStr.trim())
|
||||
for (int i = 1; i <= fileNums/3; i++)
|
||||
{
|
||||
// 读取输入和预期输出
|
||||
//由于文件的名字的命名是有规律的,所以可以直接以序号来拼接成文件名
|
||||
def inI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.in'
|
||||
def expectedOutI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.out'
|
||||
def isPublicI = readFile '../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.isPublic'
|
||||
//取出文件执行得到结果,然后和预期输出比较就可以判断正误
|
||||
// 从in.txt读入,程序运行输出重定向到out.txt
|
||||
|
||||
catchError
|
||||
{
|
||||
sh script: arg.executeCommand + 'executeFile.out < ../testCases/' + arg.trainingID + '/' + arg.challengeStage + '/' + i + '.in > actual_result_' + arg.challengeStage + '_' + i + '.out 2>&1 '
|
||||
}
|
||||
|
||||
def outI = readFile 'actual_result_' + arg.challengeStage + '_' + i + '.out'
|
||||
|
||||
// 拼接成json格式
|
||||
input.append("\"" + base64Encode(inI) + "\",");
|
||||
output.append("\"" + base64Encode(outI) + "\",");
|
||||
expectedOut.append("\"" + base64Encode(expectedOutI) + "\",");
|
||||
isPublic.append("\"" + isPublicI + "\",");
|
||||
|
||||
}
|
||||
|
||||
input = input.deleteCharAt(input.length() - 1);
|
||||
input = input.append("]");
|
||||
|
||||
output = output.deleteCharAt(output.length() - 1);
|
||||
output = output.append("]");
|
||||
|
||||
expectedOut = expectedOut.deleteCharAt(expectedOut.length() - 1);
|
||||
expectedOut = expectedOut.append("]");
|
||||
|
||||
isPublic = isPublic.deleteCharAt(isPublic.length() - 1);
|
||||
isPublic = isPublic.append("]");
|
||||
// 由中间层判断结果之后发送给BDWeb
|
||||
postGameInstanceResultToBDWeb(compileResult: base64Encode(compileResult), out: output, in:input, expectedOut:expectedOut , isPublic:isPublic)
|
||||
}
|
||||
// 传送运行结果到BDWeb
|
||||
def postGameInstanceResultToBDWeb(def arg){
|
||||
def s = 'compileResult=' + arg.compileResult + '&out=' + arg.out +
|
||||
|
@ -51,79 +128,4 @@ def postErrorToBDWeb(def arg){
|
|||
|
||||
def base64Encode(arg) {
|
||||
return arg.bytes.encodeBase64().toString()
|
||||
}
|
||||
def buildJob(def arg){
|
||||
//生成编译文件路径,c++编译多文件可以使用g++ /*.cpp这种形式把所有的cpp全部编译
|
||||
compileFile = new StringBuilder(arg.challengeProgramName);
|
||||
lastPositon = compileFile.lastIndexOf('/');
|
||||
compileFile = compileFile.substring(0,lastPositon+1) + '*.cpp';
|
||||
compileResult = ''
|
||||
try
|
||||
{
|
||||
// 编译程序
|
||||
sh script: arg.compileCommand + ' ' + compileFile + ' -o executeFile.out > compile_result_' + arg.challengeStage + '.out 2>&1'
|
||||
} catch(err)
|
||||
{
|
||||
//resubmit是以字符串的形式传进来的
|
||||
//重复构建时需要删除之前构建的成功的class并catch掉class文件不存在的异常
|
||||
catchError{
|
||||
sh 'rm executeFile.out'
|
||||
}
|
||||
}
|
||||
|
||||
//获取编译结果
|
||||
compileResult = readFile ('compile_result_' + arg.challengeStage + '.out')
|
||||
|
||||
// 如果编译通过
|
||||
if (compileResult.trim() == '') {
|
||||
compileResult = 'compile successfully'
|
||||
}
|
||||
|
||||
|
||||
StringBuilder input = new StringBuilder('[')
|
||||
StringBuilder output = new StringBuilder('[')
|
||||
StringBuilder expectedOut = new StringBuilder('[')
|
||||
StringBuilder isPublic = new StringBuilder('[')
|
||||
//得到文件夹下的文件总数
|
||||
def fileNumsStr = sh script: 'cd ../testCases/' + arg.trainindID + '/' + arg.challengeStage + ' && ls -l |grep "^-"|wc -l', returnStdout: true
|
||||
def fileNums = Integer.parseInt(fileNumsStr.trim())
|
||||
for (int i = 1; i <= fileNums/3; i++) {
|
||||
// 读取输入和预期输出
|
||||
//由于文件的名字的命名是有规律的,所以可以直接以序号来拼接成文件名
|
||||
def inI = readFile '../testCases/' + arg.trainindID + '/' + arg.challengeStage + '/' + i + '.in'
|
||||
def expectedOutI = readFile '../testCases/' + arg.trainindID + '/' + arg.challengeStage + '/' + i + '.out'
|
||||
def isPublicI = readFile '../testCases/' + arg.trainindID + '/' + arg.challengeStage + '/' + i + '.isPublic'
|
||||
//取出文件执行得到结果,然后和预期输出比较就可以判断正误
|
||||
// 从in.txt读入,程序运行输出重定向到out.txt
|
||||
|
||||
catchError
|
||||
{
|
||||
sh script: arg.executeCommand + 'executeFile.out < ../testCases/' + arg.trainindID + '/' + arg.challengeStage + '/' + i + '.in > actual_result_' + arg.challengeStage + '_' + i + '.out 2>&1 '
|
||||
}
|
||||
|
||||
def outI = readFile 'actual_result_' + arg.challengeStage + '_' + i + '.out'
|
||||
|
||||
// 拼接成json格式
|
||||
input.append("\"" + base64Encode(inI) + "\",");
|
||||
output.append("\"" + base64Encode(outI) + "\",");
|
||||
expectedOut.append("\"" + base64Encode(expectedOutI) + "\",");
|
||||
isPublic.append("\"" + isPublicI + "\",");
|
||||
|
||||
}
|
||||
|
||||
input = input.deleteCharAt(input.length() - 1);
|
||||
input = input.append("]");
|
||||
|
||||
output = output.deleteCharAt(output.length() - 1);
|
||||
output = output.append("]");
|
||||
|
||||
expectedOut = expectedOut.deleteCharAt(expectedOut.length() - 1);
|
||||
expectedOut = expectedOut.append("]");
|
||||
|
||||
isPublic = isPublic.deleteCharAt(isPublic.length() - 1);
|
||||
isPublic = isPublic.append("]");
|
||||
// 由中间层判断结果之后发送给BDWeb
|
||||
postGameInstanceResultToBDWeb(compileResult: base64Encode(compileResult), out: output, in:input, expectedOut:expectedOut , isPublic:isPublic)
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue