lili
This commit is contained in:
parent
866ac6b1cc
commit
bc119ee10f
|
@ -2,3 +2,4 @@
|
|||
.idea/
|
||||
*.iml
|
||||
target/
|
||||
2017*
|
||||
|
|
|
@ -99,7 +99,7 @@ public class Job extends BaseModel {
|
|||
*/
|
||||
public QueueReference build(Map<String, String> params) throws IOException {
|
||||
String qs = join(Collections2.transform(params.entrySet(), new MapEntryToQueryStringPair()), "&");
|
||||
client.post(url + "buildWithParameters?" + qs);
|
||||
// client.post(url + "buildWithParameters?" + qs);
|
||||
ExtractHeader location = client.post(url + "buildWithParameters?" + qs, null, ExtractHeader.class, false);
|
||||
return new QueueReference(location.getLocation());
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package test;
|
|||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.offbytwo.jenkins.JenkinsServer;
|
||||
|
@ -31,10 +32,13 @@ import com.offbytwo.jenkins.model.JobWithDetails;
|
|||
public class FirstTest {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI("http://106.75.33.219:30001"), "root", "root");
|
||||
// JenkinsServer jenkins = new JenkinsServer(new URI("http://106.75.33.219:30001"), "root", "root");
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI("http://106.75.78.183:9999/jenkins"), "guange", "123456");
|
||||
Map<String, Job> jobs = jenkins.getJobs();
|
||||
JobWithDetails job = jobs.get("testEcho").details();
|
||||
job.build();
|
||||
JobWithDetails job = jobs.get("3").details();
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("taskId", "3");
|
||||
job.build(params);
|
||||
System.out.println(job.getName());
|
||||
} catch (URISyntaxException e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
*/
|
||||
package cn.lili.test;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -22,8 +26,6 @@ import com.offbytwo.jenkins.model.BuildWithDetails;
|
|||
import com.offbytwo.jenkins.model.Job;
|
||||
import com.offbytwo.jenkins.model.JobWithDetails;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <一句话功能简述> <功能详细描述>
|
||||
*
|
||||
|
@ -37,46 +39,53 @@ public class MyTest {
|
|||
public String url = "http://106.75.33.219:30001";
|
||||
public String username = "root";
|
||||
public String password = "root";
|
||||
// public String url = "http://106.75.78.183:9999/jenkins";
|
||||
// public String username = "guange";
|
||||
// public String password = "123456";
|
||||
|
||||
// public String url = "http://106.75.78.183:8888/";
|
||||
// public String username = "root";
|
||||
// public String password = "root";
|
||||
|
||||
// public String url = "http://106.75.78.183:9999/jenkins";
|
||||
// public String username = "guange";
|
||||
// public String password = "123456";
|
||||
public String time=TimeHandle.printNowTime().replace('/', '-').replace(":", "-");
|
||||
// public String fileName1=time+"-series.txt";
|
||||
// public String fileName2=time+"-parallel.txt";
|
||||
public String fileName2=time.split(" ")[0];
|
||||
// public String filePath=System.getProperty("user.dir")+"\\"+fileName1;
|
||||
|
||||
public String filePath=System.getProperty("user.dir")+"\\"+fileName2;
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI("http://106.75.33.219:30001"), "root", "root");
|
||||
Map<String, Job> jobs = jenkins.getJobs();
|
||||
JobWithDetails job = jobs.get("test").details();
|
||||
job.build();
|
||||
System.out.println(job.getName());
|
||||
} catch (URISyntaxException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getAllJobs() throws Exception {
|
||||
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI(url), username, password);
|
||||
Map<String, Job> jobs=jenkins.getJobs();
|
||||
for (Entry<String, Job> entry:jobs.entrySet()) {
|
||||
// JenkinsServer jenkins = new JenkinsServer(new URI("http://106.75.33.219:30001"), "root", "root");
|
||||
// Map<String, Job> jobs = jenkins.getJobs();
|
||||
// JobWithDetails job = jobs.get("test").details();
|
||||
//// job.build();
|
||||
// System.out.println(job.getName());
|
||||
|
||||
System.out.println(entry.getKey());
|
||||
|
||||
System.out.println(System.getProperty("user.dir"));
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getAllJobs() throws Exception {
|
||||
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI(url), username, password);
|
||||
Map<String, Job> jobs = jenkins.getJobs();
|
||||
for (Entry<String, Job> entry : jobs.entrySet()) {
|
||||
|
||||
System.out.println(entry.getKey());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @Test
|
||||
// @Test
|
||||
public void createJob() throws Exception {
|
||||
int count = 10;
|
||||
int count = 20;
|
||||
for (int i = 0; i < count; i++) {
|
||||
String jobname=i+"";
|
||||
String jobname = i + "";
|
||||
System.out.println(jobname);
|
||||
createOneJob(jobname);
|
||||
}
|
||||
|
@ -84,13 +93,12 @@ public class MyTest {
|
|||
|
||||
// @Test
|
||||
public void deleteJob() throws Exception {
|
||||
int count = 100;
|
||||
int count = 20;
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI(url), username, password);
|
||||
Map<String, Job> jobs=jenkins.getJobs();
|
||||
Map<String, Job> jobs = jenkins.getJobs();
|
||||
for (int i = 0; i < count; i++) {
|
||||
String jobname=i+"";
|
||||
if(jobs.containsKey(jobname))
|
||||
{
|
||||
String jobname = i + "";
|
||||
if (jobs.containsKey(jobname)) {
|
||||
System.out.println(jobname);
|
||||
deleteOneJob(jobname);
|
||||
|
||||
|
@ -98,43 +106,90 @@ public class MyTest {
|
|||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
// @Test
|
||||
public void buildJob() throws Exception {
|
||||
int count = 1;
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI(url), username, password);
|
||||
PrintStream ps=new PrintStream(new FileOutputStream(filePath,true));
|
||||
System.setOut(ps);
|
||||
int count = 20;
|
||||
for (int i = 0; i < count; i++) {
|
||||
buildOneJob(1 + "");
|
||||
|
||||
buildOneJob(i + "");
|
||||
// buildOneJob("3");
|
||||
Thread.sleep(30 * 1000);
|
||||
getOneBuild(i + "", new JenkinsServer(new URI(url), username, password));
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void buildJobNoparam() throws Exception {
|
||||
int count = 1;
|
||||
for (int i = 0; i < count; i++) {
|
||||
buildOneJobNoparam("1");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildJobParallel() throws Exception {
|
||||
PrintStream ps=new PrintStream(new FileOutputStream(filePath,true));
|
||||
System.setOut(ps);
|
||||
int count = 10;
|
||||
for (int i = 0; i < count; i++) {
|
||||
buildOneJob(i + "");
|
||||
// buildOneJob("3");
|
||||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void buildJobNoparam() throws Exception {
|
||||
int count = 1;
|
||||
for (int i = 0; i < count; i++) {
|
||||
buildOneJobNoparam("1");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getBuilds() throws Exception {
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI(url), username, password);
|
||||
Map<String, Job> jobs=jenkins.getJobs();
|
||||
|
||||
int count = 2;
|
||||
for (int i = 1; i < count; i++) {
|
||||
JobWithDetails job = jobs.get("1").details();
|
||||
Build builds=job.getLastBuild();
|
||||
BuildWithDetails buildWithDetails=builds.details();
|
||||
System.out.println(buildWithDetails.getConsoleOutputText());
|
||||
}
|
||||
public void getBuilds() throws Exception {
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI(url), username, password);
|
||||
PrintStream ps=new PrintStream(new FileOutputStream(filePath,true));
|
||||
System.setOut(ps);
|
||||
int count = 20;
|
||||
for (int i = 0; i < count;i++) {
|
||||
String name = i+"";
|
||||
getOneBuild(name, jenkins);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void getOneBuild(String jobName, JenkinsServer jenkins) throws Exception {
|
||||
|
||||
Map<String, Job> jobs = jenkins.getJobs();
|
||||
JobWithDetails job = jobs.get(jobName).details();
|
||||
try {
|
||||
|
||||
BuildWithDetails buildWithDetails = job.getLastBuild().details();
|
||||
while (buildWithDetails.getResult() == null || buildWithDetails.getResult().name() == null) {
|
||||
buildWithDetails = job.getLastBuild().details();
|
||||
}
|
||||
String buildId = buildWithDetails.getId();
|
||||
long startTime = buildWithDetails.getTimestamp();
|
||||
long duration = buildWithDetails.getDuration();
|
||||
long estimatedDuration = buildWithDetails.getEstimatedDuration();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String startDate = simpleDateFormat.format(new Date(startTime));
|
||||
// String durationDate = simpleDateFormat.format(new
|
||||
// Date(startTime));
|
||||
String endDate = simpleDateFormat.format(new Date(startTime + duration));
|
||||
String salveName=StringUtil.getSalveName(buildWithDetails);
|
||||
System.out.println(
|
||||
"taskId: " + jobName + "#" + buildId + "," +startDate + "," + endDate+ "," + salveName);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
Thread.sleep(1 * 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void createOneJob(String jobName) {
|
||||
try {
|
||||
String pipeLine = "podTemplate(label: 'mypod', containers: ["
|
||||
+ "containerTemplate(name: 'openjdk', image: 'openjdk', ttyEnabled: true)]) \n "
|
||||
+ "{ \n node('mypod'){ \n container('openjdk') { \n" + "stage 'first' \n" + "echo 'hello Word'\n }}}";
|
||||
+ "containerTemplate(name: 'ubuntu', image: 'ubuntu', ttyEnabled: true)]) \n "
|
||||
+ "{ \n node('mypod'){ \n container('ubuntu') { \n" + "stage 'first' \n"
|
||||
+ "echo 'hello Word'\n }}}";
|
||||
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("taskId", jobName);
|
||||
|
@ -151,12 +206,12 @@ public class MyTest {
|
|||
try {
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI(url), username, password);
|
||||
JobWithDetails job = jenkins.getJob(jobName);
|
||||
System.out.print(jobName+"\t");
|
||||
System.out.print(jobName + "\t");
|
||||
TimeHandle.printNowTime();
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("taskId", jobName);
|
||||
job.build(params);
|
||||
|
||||
params.put("taskId", jobName);
|
||||
job.build(params);
|
||||
|
||||
TimeHandle.printNowTime();
|
||||
System.out.println("");
|
||||
} catch (Exception e) {
|
||||
|
@ -164,15 +219,16 @@ public class MyTest {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void buildOneJobNoparam(String jobName) {
|
||||
try {
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI(url), username, password);
|
||||
JobWithDetails job = jenkins.getJob(jobName);
|
||||
System.out.print(jobName+"\t");
|
||||
System.out.print(jobName + "\t");
|
||||
TimeHandle.printNowTime();
|
||||
|
||||
job.build();
|
||||
|
||||
|
||||
job.build();
|
||||
|
||||
TimeHandle.printNowTime();
|
||||
System.out.println("");
|
||||
} catch (Exception e) {
|
||||
|
@ -180,6 +236,7 @@ public class MyTest {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteOneJob(String jobName) {
|
||||
try {
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI(url), username, password);
|
||||
|
|
|
@ -1,13 +1,39 @@
|
|||
package cn.lili.test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
|
||||
import com.offbytwo.jenkins.model.BuildWithDetails;
|
||||
|
||||
/**
|
||||
* Created by guange on 18/02/2017.
|
||||
*/
|
||||
public class StringUtil {
|
||||
public static String KUBERNETES="kubernetes-";
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
public static String escapeXml(String content){
|
||||
String xml = StringEscapeUtils.escapeXml(content);
|
||||
return xml;
|
||||
}
|
||||
public static String getSalveName(BuildWithDetails buildWithDetails){
|
||||
String out;
|
||||
try {
|
||||
out = buildWithDetails.getConsoleOutputText();
|
||||
|
||||
for(String line:out.split("\n")){
|
||||
for(String item:line.split(" ")){
|
||||
if(item.startsWith(KUBERNETES)){
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "master";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,11 +25,15 @@ import org.junit.Test;
|
|||
*/
|
||||
|
||||
public class TimeHandle {
|
||||
public static void main(String[] args) {
|
||||
printNowTime();
|
||||
}
|
||||
// @Test
|
||||
public static void printNowTime(){
|
||||
public static String printNowTime(){
|
||||
Date now = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:ms");//可以方便地修改日期格式
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");//可以方便地修改日期格式
|
||||
String hehe = dateFormat.format( now );
|
||||
System.out.print(hehe+"\t");
|
||||
return hehe;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import cn.guange.app.jenkins.utils.ReadFileUtil;
|
|||
import com.offbytwo.jenkins.JenkinsServer;
|
||||
import com.offbytwo.jenkins.model.Job;
|
||||
import com.offbytwo.jenkins.model.JobWithDetails;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -24,96 +26,106 @@ import java.util.Set;
|
|||
*/
|
||||
public class JenkinsTest extends SpringTestBase {
|
||||
|
||||
@Autowired
|
||||
AppConfig appConfig;
|
||||
@Autowired
|
||||
AppConfig appConfig;
|
||||
|
||||
@Autowired
|
||||
JenkinsApi jenkinsApi;
|
||||
@Autowired
|
||||
JenkinsApi jenkinsApi;
|
||||
|
||||
// @Test
|
||||
public void createJob() {
|
||||
// 创建job
|
||||
String pipeLine = ReadFileUtil.readPipeline("src/test/resources/pipeline");
|
||||
Map<String,String> params = new HashMap<String,String>();
|
||||
params.put("gitUrl", "1");
|
||||
params.put("step", "1");
|
||||
params.put("taskId", "1");
|
||||
params.put("testCode", "");
|
||||
for (int i = 0; i < 20; i++) {
|
||||
try {
|
||||
jenkinsApi.createJob("test_time" + i, pipeLine, params);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfig(){
|
||||
Assert.assertTrue(appConfig!=null);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildJob() throws Exception {
|
||||
jenkinsApi.buildJob("test", "1", "2", "https://bdgit.trustie.net/forge01/linkedlistdemo.git", "{}");
|
||||
}
|
||||
@Test
|
||||
public void getJobTime() throws Exception {
|
||||
System.setOut(new PrintStream("sendBuildRequestTime.log"));
|
||||
//
|
||||
|
||||
@Test
|
||||
public void getJobTime() throws Exception {
|
||||
System.setOut(new PrintStream("sendBuildRequestTime.log"));
|
||||
//
|
||||
// 创建job
|
||||
// String pipeLine = ReadFileUtil.readPipeline("src/test/resources/pipeline");
|
||||
// Map params = new HashMap();
|
||||
// params.put("gitUrl", "1");
|
||||
// params.put("step", "1");
|
||||
// params.put("taskId", "1");
|
||||
// params.put("testCode", "");
|
||||
// for(int i = 0; i < 10; i++) {
|
||||
// jenkinsApi.createJob( "test_time" + i, pipeLine, params);
|
||||
// }
|
||||
//
|
||||
// 构建job
|
||||
for (int i = 0; i < 10; i++) {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||
System.out.println("taskId: " + i + ", " + df.format(new Date()));
|
||||
jenkinsApi.buildJob("test_time" + i, i + "", "2", "https://bdgit.trustie.net/forge01/linkedlistdemo.git", "{}");
|
||||
}
|
||||
// 获取构建信息
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI(appConfig.getJenkinsUrl()),
|
||||
appConfig.getJenkisUserName(), appConfig.getJenkisPassWord());
|
||||
// 构建job
|
||||
// for (int i = 0; i < 10; i++) {
|
||||
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||
// System.out.println("taskId: " + i + ", " + df.format(new Date()));
|
||||
// jenkinsApi.buildJob("test_time" + i, i + "", "2", "https://bdgit.trustie.net/forge01/linkedlistdemo.git",
|
||||
// "{}");
|
||||
// }
|
||||
// 获取构建信息
|
||||
JenkinsServer jenkins = new JenkinsServer(new URI(appConfig.getJenkinsUrl()), appConfig.getJenkisUserName(),
|
||||
appConfig.getJenkisPassWord());
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
JobWithDetails job = jenkins.getJob("test_time" + i);
|
||||
for (int i = 0; i < 10; ) {
|
||||
JobWithDetails job = jenkins.getJob("" + i);
|
||||
try {
|
||||
String output = job.getLastSuccessfulBuild().details().getConsoleOutputText();
|
||||
// System.out.println(i + " " + output.indexOf("jenkins start build
|
||||
// time") + "\n" + output);
|
||||
String startTime = output.substring(output.indexOf("jenkins start build time"));
|
||||
startTime = startTime.substring(0, startTime.indexOf("[")).trim();
|
||||
startTime = startTime.substring(25, 49);
|
||||
String endTime = output.substring(output.indexOf("jenkins build finished time"));
|
||||
endTime = endTime.substring(0, endTime.indexOf("[")).trim();
|
||||
endTime = endTime.substring(28, 52);
|
||||
String node = output.substring(output.indexOf("Running on"));
|
||||
node = node.substring(11, node.indexOf(" in "));
|
||||
System.out.println("taskId: " + i + "," + startTime + "," + endTime + "," + node);
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
Thread.sleep(1 * 1000);
|
||||
e.printStackTrace();
|
||||
}
|
||||
// while (job.getLastSuccessfulBuild() == null || job.getLastSuccessfulBuild().details() == null) {
|
||||
// Thread.sleep(1 * 1000);
|
||||
// }
|
||||
// while (job.getLastSuccessfulBuild().details().getResult() == null
|
||||
// || !"SUCCESS".equals(job.getLastSuccessfulBuild().details().getResult().toString())) {
|
||||
// Thread.sleep(1 * 1000);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
while (job.getLastSuccessfulBuild() == null || job.getLastSuccessfulBuild().details() == null) {
|
||||
}
|
||||
while(job.getLastSuccessfulBuild().details().getResult()==null || !"SUCCESS".equals(job.getLastSuccessfulBuild().details().getResult().toString())) {
|
||||
}
|
||||
String output = job.getLastSuccessfulBuild().details().getConsoleOutputText();
|
||||
// System.out.println(i + " " + output.indexOf("jenkins start build time") + "\n" + output);
|
||||
String startTime = output.substring(output.indexOf("jenkins start build time"));
|
||||
startTime = startTime.substring(0, startTime.indexOf("[")).trim();
|
||||
startTime = startTime.substring(25, 49);
|
||||
String endTime = output.substring(output.indexOf("jenkins build finished time"));
|
||||
endTime = endTime.substring(0, endTime.indexOf("[")).trim();
|
||||
endTime = endTime.substring(28, 52);
|
||||
String node = output.substring(output.indexOf("Running on"));
|
||||
node = node.substring(11, node.indexOf(" in "));
|
||||
System.out.println("taskId: " + i + " , " + startTime + ", " + endTime + ", " + node);
|
||||
}
|
||||
|
||||
}
|
||||
// @Test
|
||||
public void getJobXml() throws Exception {
|
||||
String test = jenkinsApi.getJobXml("jenkins_param_test");
|
||||
System.out.println(test);
|
||||
}
|
||||
|
||||
}
|
||||
// @Test
|
||||
public void teardown() {
|
||||
try {
|
||||
JenkinsServer jenkinsServer = new JenkinsServer(new URI(appConfig.getJenkinsUrl()),
|
||||
appConfig.getJenkisUserName(), appConfig.getJenkisPassWord());
|
||||
// Map<String, Job> jobs = jenkinsServer.getJobs();
|
||||
// Set<Map.Entry<String, Job>> entries = jobs.entrySet();
|
||||
// for(Map.Entry<String, Job> entry: entries) {
|
||||
// if(jenkinsServer.getJob(entry.getKey()) != null) {
|
||||
// jenkinsServer.deleteJob(entry.getKey());
|
||||
// }
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void getJobXml() throws Exception {
|
||||
String test = jenkinsApi.getJobXml("jenkins_param_test");
|
||||
System.out.println(test);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void teardown() {
|
||||
try {
|
||||
JenkinsServer jenkinsServer = new JenkinsServer(new URI(appConfig.getJenkinsUrl()),
|
||||
appConfig.getJenkisUserName(), appConfig.getJenkisPassWord());
|
||||
// Map<String, Job> jobs = jenkinsServer.getJobs();
|
||||
// Set<Map.Entry<String, Job>> entries = jobs.entrySet();
|
||||
// for(Map.Entry<String, Job> entry: entries) {
|
||||
// if(jenkinsServer.getJob(entry.getKey()) != null) {
|
||||
// jenkinsServer.deleteJob(entry.getKey());
|
||||
// }
|
||||
// }
|
||||
|
||||
for(int i = 0; i < 30; i++)
|
||||
if (jenkinsServer.getJob("test_time" + i) != null) {
|
||||
jenkinsServer.deleteJob("test_time" + i);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 30; i++)
|
||||
if (jenkinsServer.getJob("test_time" + i) != null) {
|
||||
jenkinsServer.deleteJob("test_time" + i);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
### 设置###
|
||||
log4j.rootLogger = debug,stdout
|
||||
log4j.rootLogger = stdout
|
||||
|
||||
### 输出信息到控制抬 ###
|
||||
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
||||
|
|
Loading…
Reference in New Issue