增加jdbc pipeline
This commit is contained in:
parent
3a8834b4d8
commit
6e32bb1b21
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.wst.validation.validationbuilder"/>
|
||||
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
</launchConfiguration>
|
|
@ -134,11 +134,10 @@ public class GameController extends BaseController {
|
|||
|
||||
pipeline = generatePipeline.generateChallengePipeline(params);
|
||||
|
||||
|
||||
response.put("code", 0);
|
||||
response.put("msg", Base64Helper.encode(pipeline));
|
||||
|
||||
// logger.debug("/game/generatePipelineScriptForChallenge challengeInfo:
|
||||
// " + challengeInfo);
|
||||
logger.debug(response.toJSONString());
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -184,7 +183,7 @@ public class GameController extends BaseController {
|
|||
params.put("challengePipeline", new String(challengePipeline));
|
||||
params.put("pipelineTemplateFileName", pipeLineConfig.getPipelineTemplateFileName().get(index));
|
||||
params.put("podTemplate",pipeLineConfig.getPodTemplate().get(index));
|
||||
|
||||
params.put("mainContainer",pipeLineConfig.getMainContainer().get(index));
|
||||
// 根据运行环境分别得到对应的编译和执行命令
|
||||
GeneratePipeline generatePipeline = (GeneratePipeline) Class
|
||||
.forName(pipeLineConfig.getClassName().get(index)).newInstance();
|
||||
|
@ -195,7 +194,7 @@ public class GameController extends BaseController {
|
|||
response.put("code", 0);
|
||||
response.put("msg", Base64Helper.encode(pipeline));
|
||||
|
||||
// logger.debug("*****/game/generatePipelineScriptForGame gameInfo: " + gameInfo);
|
||||
logger.debug(response.toJSONString());
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -215,7 +214,7 @@ public class GameController extends BaseController {
|
|||
// instanceGitURL为学生fork的版本库的地址
|
||||
jenkinsController.buildJobForInstance(jobNameForInstance, instanceGitURL, 0 + "", 0 + "", 0 + "");
|
||||
|
||||
logger.debug("*****/game/openGameInstance jobNameForInstance: " + jobNameForInstance);
|
||||
logger.debug(response.toJSONString());
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -292,35 +291,33 @@ public class GameController extends BaseController {
|
|||
* @return: 0 删除成功
|
||||
* -1 删除失败
|
||||
* */
|
||||
@ApiOperation(value = "删除Job及工作目录下的文件", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
@RequestMapping(path = "/deleteJob")
|
||||
public JSONObject deleteJob(
|
||||
@ApiParam(name = "delJob", required = true, value = "要删除的job的名字") @RequestParam String delJob)
|
||||
throws Exception {
|
||||
@ApiOperation(value = "删除Job及工作目录下的文件", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
@RequestMapping(path = "/deleteJob")
|
||||
public JSONObject deleteJob(@ApiParam(name = "jobName", required = true, value = "要删除的job的名字") @RequestParam String jobName) throws Exception {
|
||||
logger.debug("jobName: " + jobName);
|
||||
String job = Base64Helper.decode(jobName);
|
||||
JSONObject response = new JSONObject();
|
||||
response.put("code",-1);
|
||||
//调用Jenkins API删除job
|
||||
int result= jenkinsApi.deleteJob(job);
|
||||
|
||||
JSONObject info = JSONObject.parseObject(delJob);
|
||||
String job = info.getString("jobName");
|
||||
/*
|
||||
* -1:删除之前job 存在,删除未成功
|
||||
* 1;要删除的job不存在(此时不用删除Jenkins工作目录下的文件)
|
||||
* 0:删除成功
|
||||
* */
|
||||
if(-1 == result)
|
||||
{
|
||||
response.put("code",-1);
|
||||
return response;
|
||||
}
|
||||
|
||||
JSONObject response = new JSONObject();
|
||||
response.put("status", -1);
|
||||
// 调用Jenkins API删除job
|
||||
int result = jenkinsApi.deleteJob(job);
|
||||
|
||||
/*
|
||||
* -1:删除之前job 存在,删除未成功
|
||||
* 1;要删除的job不存在(此时不用删除Jenkins工作目录下的文件)
|
||||
* 0:删除成功
|
||||
* */
|
||||
if (-1 == result) {
|
||||
response.put("status", -1);
|
||||
return response;
|
||||
}
|
||||
|
||||
if (1 == result || 0 == result) {
|
||||
response.put("status", 0);
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
if(1 == result || 0==result)
|
||||
{
|
||||
response.put("code",0);
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ public class GeneratePipelineJava extends GeneratePipeline{
|
|||
|
||||
//提取执行文件名称
|
||||
String replacedStr[]=params.get("replaceExecuteCommand").split("#");
|
||||
if(replacedStr.length<2){ throw new ArrayIndexOutOfBoundsException("提取执行文件名称的替换有误");}
|
||||
|
||||
String executeFileName = params.get("challengeProgramName").replace(replacedStr[0], replacedStr[1]);
|
||||
|
||||
pipeline = pipeline.replace("COMPILECOMMAND", params.get("complieCommand"));
|
||||
|
@ -76,10 +78,10 @@ public class GeneratePipelineJava extends GeneratePipeline{
|
|||
String podTemplate=params.get("podTemplate");
|
||||
String pipelineTemplateFileName=params.get("pipelineTemplateFileName");
|
||||
String challengePipeline=params.get("challengePipeline");
|
||||
|
||||
String mainContainer=params.get("mainContainer");
|
||||
String fullPipeline=StringUtil.getCofigureFileContent(pipelineTemplateFileName);
|
||||
|
||||
fullPipeline=podTemplate+fullPipeline.replace("CHALLENGEPIPELINES", challengePipeline);
|
||||
fullPipeline=fullPipeline.replaceFirst("MAINCONTAINER", mainContainer).replace("CHALLENGEPIPELINES", challengePipeline);
|
||||
fullPipeline=podTemplate+fullPipeline;
|
||||
return fullPipeline;
|
||||
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
<bean id="pipeLineConfig" class="com.educoder.jenkins.settings.PipeLineConfig">
|
||||
<property name="environment">
|
||||
<list>
|
||||
<value>java</value>
|
||||
<value>python</value>
|
||||
<value>jdbc</value>
|
||||
<value>Java</value>
|
||||
<value>Python</value>
|
||||
<value>JDBC</value>
|
||||
</list>
|
||||
</property>
|
||||
|
||||
|
@ -86,9 +86,9 @@
|
|||
|
||||
<property name="replaceExecuteCommand">
|
||||
<list>
|
||||
<value>.java#</value>
|
||||
<value>.py#.py</value>
|
||||
<value>.java#</value>
|
||||
<value>.java# </value>
|
||||
<value>.py#.py </value>
|
||||
<value>.java# </value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
node(PODLABEL) {
|
||||
|
||||
node('PODLABEL') {
|
||||
container('MAINCONTAINER') {
|
||||
def currentChallenge = Integer.parseInt(instanceChallenge)
|
||||
// 解决stage 0 401没有权限的问题
|
||||
if (currentChallenge == 0) {
|
||||
|
@ -22,7 +22,7 @@ node(PODLABEL) {
|
|||
git url: instanceGitURL
|
||||
|
||||
CHALLENGEPIPELINES
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// 传送运行结果到BDWeb
|
||||
|
|
|
@ -2,4 +2,4 @@ workspace=/var/lib/jenkins/workspace
|
|||
remoteWorkspace=/home/jenkins
|
||||
java_podTemplate=podTemplate(label: 'PODLABEL', containers: [containerTemplate(name: 'openjdk', image: 'openjdk:latest', ttyEnabled: true)],volumes:[hostPathVolume(hostPath: '${workspace}', mountPath: '${remoteWorkspace}')])
|
||||
python_podTemplate=podTemplate(label: 'PODLABEL', containers: [containerTemplate(name: 'python', image: 'python:latest', ttyEnabled: true)],volumes:[hostPathVolume(hostPath: '${workspace}', mountPath: '${remoteWorkspace}')])
|
||||
jdbc_podTemplate=null
|
||||
jdbc_podTemplate=podTemplate(label: 'PODLABEL', containers: [containerTemplate(name: 'openjdk', image: 'openjdk:latest', ttyEnabled: true), containerTemplate(name: 'mysql', image: 'mysql57:latest', ttyEnabled: true, command: '/start.sh')],volumes:[hostPathVolume(hostPath: '${workspace}', mountPath: '${remoteWorkspace}')])
|
||||
|
|
|
@ -18,7 +18,8 @@ public class TestString {
|
|||
@Test
|
||||
public void testMap(){
|
||||
Map<String,String> testmap=new HashMap<String,String>();
|
||||
System.out.println(testmap.get(null));
|
||||
testmap.put("1", " "+"1"+" ");
|
||||
System.out.println(testmap.get("1"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue