开启实训与生成测试用例文件
This commit is contained in:
parent
3f10f7a549
commit
106ae7bb92
|
@ -107,13 +107,13 @@ public class JenkinsApi {
|
|||
job.build(buildParams);
|
||||
}
|
||||
|
||||
public void buildJob(String jobName, String taskId, String step, String gitUrl) throws IOException {
|
||||
JobWithDetails job = jenkins.getJob(jobName);
|
||||
public void buildJob(String jobNameForInstance, String buildID, String instanceChallenge, String instanceGitURL) throws IOException {
|
||||
JobWithDetails job = jenkins.getJob(jobNameForInstance);
|
||||
Map<String, String> buildParams = new HashMap();
|
||||
buildParams.put("taskId", taskId);
|
||||
buildParams.put("step", step);
|
||||
buildParams.put("gitUrl", gitUrl);
|
||||
|
||||
buildParams.put("buildID", buildID);
|
||||
buildParams.put("instanceChallenge", instanceChallenge);
|
||||
buildParams.put("instanceGitURL", instanceGitURL);
|
||||
|
||||
job.build(buildParams);
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ public class GameController extends BaseController {
|
|||
@ApiParam(name = "instanceGitURL", required = true, value = "job的gitUrl") @RequestParam String instanceGitURL) {
|
||||
JSONObject result = jenkinsController.createJobForInstance(jobNameForInstance, gamePipelineScript);
|
||||
|
||||
jenkinsController.buildJobForInstance(jobNameForInstance, instanceGitURL, 0, 0);
|
||||
jenkinsController.buildJobForInstance(jobNameForInstance, instanceGitURL, 0 + "", 0 + "");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -50,20 +50,19 @@ public class JenkinsController {
|
|||
|
||||
@ApiOperation(value = "创建一个job", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
@ApiResponse(code = 200, message = "success", response = JSONObject.class)
|
||||
@RequestMapping(path="/createJob",method = RequestMethod.POST)
|
||||
@RequestMapping(path="/createJobForInstance",method = RequestMethod.POST)
|
||||
public JSONObject createJobForInstance(@ApiParam(name = "jobNameForInstance", required = true, value = "job的名字,不能重复") @RequestParam String jobNameForInstance,
|
||||
@ApiParam(name = "gamePipelineScript", required = true, value = "pipeLine脚本,用base64编码") @RequestParam String gamePipelineScript,
|
||||
@ApiParam(name = "jobParams", required = true, value = "job的参数,以json字符串的形式") @RequestParam String jobParams
|
||||
@ApiParam(name = "gamePipelineScript", required = true, value = "pipeLine脚本,用base64编码") @RequestParam String gamePipelineScript
|
||||
){
|
||||
|
||||
JSONObject response = new JSONObject();
|
||||
try {
|
||||
Map jobParamsMap = JSONObject.parseObject(jobParams, Map.class);
|
||||
for (Object key : jobParamsMap.keySet()) {
|
||||
jobParamsMap.put(key, "");
|
||||
}
|
||||
Map jobParamsMap = new HashMap();
|
||||
jobParamsMap.put("instanceGitURL", "");
|
||||
jobParamsMap.put("instanceChallenge", "");
|
||||
jobParamsMap.put("buildID", "");
|
||||
|
||||
logger.debug("调用[createJob]: jobName=" + jobNameForInstance + " pipeLine=" + gamePipelineScript + JSONObject.toJSONString(jobParams));
|
||||
logger.debug("调用[createJob]: jobName=" + jobNameForInstance + " pipeLine=" + gamePipelineScript);
|
||||
|
||||
gamePipelineScript = Base64Helper.decode(gamePipelineScript);
|
||||
|
||||
|
@ -88,17 +87,17 @@ public class JenkinsController {
|
|||
}
|
||||
|
||||
@ApiOperation(value = "构建一个job", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
@RequestMapping(path="/buildJob")
|
||||
public JSONObject buildJob(@ApiParam(name = "jobNameForInstance", required = true, value = "job的名字") @RequestParam String jobNameForInstance,
|
||||
@RequestMapping(path="/buildJobForInstance")
|
||||
public JSONObject buildJobForInstance(@ApiParam(name = "jobNameForInstance", required = true, value = "job的名字") @RequestParam String jobNameForInstance,
|
||||
@ApiParam(name = "instanceGitURL", required = true, value = "学员对应当前实训版本库地址") @RequestParam String instanceGitURL,
|
||||
@ApiParam(name = "buildID", required = true, value = "本次评测ID") @RequestParam String buildID,
|
||||
@ApiParam(name = "instanceStage", required = true, value = "当前处在第几关") @RequestParam String instanceStage
|
||||
@ApiParam(name = "instanceChallenge", required = true, value = "当前处在第几关") @RequestParam String instanceChallenge
|
||||
){
|
||||
JSONObject response = new JSONObject();
|
||||
try {
|
||||
logger.debug("调用[buildJob]: jobName=" + jobNameForInstance + "taskId "+buildID+" step "+instanceStage+" gitUrl "+instanceGitURL);
|
||||
logger.debug("调用[buildJob]: jobName=" + jobNameForInstance + "taskId "+buildID+" step "+instanceChallenge+" gitUrl "+instanceGitURL);
|
||||
instanceGitURL = Base64Helper.decode(instanceGitURL);
|
||||
jenkinsApi.buildJob(jobNameForInstance, buildID, instanceStage, instanceGitURL);
|
||||
jenkinsApi.buildJob(jobNameForInstance, buildID, instanceChallenge, instanceGitURL);
|
||||
}catch (Exception e){
|
||||
logger.error("buildJob", e);
|
||||
response.put("code", -1);
|
||||
|
|
Loading…
Reference in New Issue