开启实训以及写入测试用例到文件

This commit is contained in:
wangwei10061 2017-04-14 09:45:00 +08:00
parent 106ae7bb92
commit 1ad5ec5804
2 changed files with 34 additions and 1 deletions

View File

@ -165,7 +165,12 @@ 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 + "");
try {
jenkinsController.buildJobForInstance(jobNameForInstance, instanceGitURL, 0 + "", 0 + "");
} catch (Exception e) {
result.put("code", -1);
result.put("msg", "stage 0 failed");
}
return result;
}

View File

@ -2,15 +2,24 @@ package cn.wangwei.app.jenkins;
import cn.guange.app.jenkins.SpringTestBase;
import com.educoder.jenkins.controller.GameController;
import com.educoder.jenkins.settings.AppConfig;
import com.educoder.jenkins.utils.Base64Helper;
import com.offbytwo.jenkins.JenkinsServer;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
/**
* Created by weishao on 2017/4/12.
*/
public class GameControllerTest extends SpringTestBase {
@Autowired
GameController gameController;
@Autowired
AppConfig appConfig;
@Test
public void testGenerateScriptPerChallenge() {
@ -77,4 +86,23 @@ public class GameControllerTest extends SpringTestBase {
e.printStackTrace();
}
}
@Test
public void testOpenGameInstance () throws UnsupportedEncodingException {
String jobNameForInstance = "junit test case";
String gamePipelineScript = Base64Helper.encode("node () { git url: instanceGitURL }");
String instanceGitURL = Base64Helper.encode("https://git.oschina.net/hugeox/genkins-demo1.git");
System.out.println(gameController.openGameInstance(jobNameForInstance, gamePipelineScript, instanceGitURL));
try {
JenkinsServer server = new JenkinsServer(new URI(appConfig.getJenkinsUrl()), appConfig.getJenkisUserName(), appConfig.getJenkisPassWord());
if (server.getJob("junit test case") != null) {
server.deleteJob("junit test case");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}