1、hudson API create job
public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
String hudson = "http://10.20.157.179:8080/hudson/";
File configFile = new File("config.xml");
put(client, hudson, "test", configFile);
}
private static void put(HttpClient client, String hudsonBaseURL, String jobName, File configFile)
throws IOException,
HttpException {
PostMethod postMethod = new PostMethod(hudsonBaseURL + "/createItem?name=" + jobName);
client.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = new UsernamePasswordCredentials("admin", "sfhudson");
client.getState().setCredentials(new AuthScope("10.20.157.179", 8080), defaultcreds);
postMethod.setRequestHeader("Content-type", "application/xml; charset=ISO-8859-1");
postMethod.setRequestBody(new FileInputStream(configFile));
postMethod.setDoAuthentication(true);
try {
int status = client.executeMethod(postMethod);
System.out.println(status + "\n" + postMethod.getResponseBodyAsString());
} finally {
postMethod.releaseConnection();
}
}
2、update hudson job
public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
String hudson = "http://10.20.157.179:8080/hudson/";
File configFile = new File("config.xml");
put(client, hudson, "test", configFile);
}
private static void put(HttpClient client, String hudsonBaseURL, String jobName, File configFile)
throws IOException,
HttpException {
PostMethod postMethod = new PostMethod(hudsonBaseURL + "/job/" + jobName + "/config.xml");
client.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = new UsernamePasswordCredentials("admin", "sfhudson");
client.getState().setCredentials(new AuthScope("10.20.157.179", 8080), defaultcreds);
postMethod.setRequestHeader("Content-type", "application/xml; charset=ISO-8859-1");
postMethod.setRequestBody(new FileInputStream(configFile));
postMethod.setDoAuthentication(true);
try {
int status = client.executeMethod(postMethod);
System.out.println(status + "\n" + postMethod.getResponseBodyAsString());
} finally {
postMethod.releaseConnection();
}
}
3、copy hudson job
public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
String hudson = "http://10.20.157.179:8080/hudson/";
File configFile = new File("config.xml");
put(client, hudson, "test", configFile);
}
private static void put(HttpClient client, String hudsonBaseURL, String jobName, File configFile)
throws IOException,
HttpException {
PostMethod postMethod = new PostMethod(hudsonBaseURL + "/createItem");
NameValuePair n1 = new NameValuePair("name", "copyNew");
NameValuePair n2 = new NameValuePair("mode", "copy");
NameValuePair n3 = new NameValuePair("from", jobName);
postMethod.setQueryString(new NameValuePair[] { n1, n2, n3 });
client.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = new UsernamePasswordCredentials("admin", "sfhudson");
client.getState().setCredentials(new AuthScope("10.20.157.179", 8080), defaultcreds);
postMethod.setRequestHeader("Content-type", "application/xml; charset=ISO-8859-1");
postMethod.setRequestBody(new FileInputStream(configFile));
postMethod.setDoAuthentication(true);
try {
int status = client.executeMethod(postMethod);
System.out.println(status + "\n" + postMethod.getResponseBodyAsString());
} finally {
postMethod.releaseConnection();
}
}
4、delete job
public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
String hudson = "http://10.20.157.179:8080/hudson/";
put(client, hudson, "copyNew");
}
private static void put(HttpClient client, String hudsonBaseURL, String jobName) throws IOException, HttpException {
PostMethod postMethod = new PostMethod(hudsonBaseURL + "/job/" + jobName + "/doDelete");
client.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = new UsernamePasswordCredentials("admin", "sfhudson");
client.getState().setCredentials(new AuthScope("10.20.157.179", 8080), defaultcreds);
postMethod.setDoAuthentication(true);
try {
int status = client.executeMethod(postMethod);
System.out.println(status + "\n" + postMethod.getResponseBodyAsString());
} finally {
postMethod.releaseConnection();
}
}
5、enable disable job
public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
String hudson = "http://10.20.157.179:8080/hudson/";
put(client, hudson, "test");
}
private static void put(HttpClient client, String hudsonBaseURL, String jobName) throws IOException, HttpException {
PostMethod postMethod = new PostMethod(hudsonBaseURL + "/job/" + jobName + "/disable");
client.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = new UsernamePasswordCredentials("admin", "sfhudson");
client.getState().setCredentials(new AuthScope("10.20.157.179", 8080), defaultcreds);
postMethod.setDoAuthentication(true);
try {
int status = client.executeMethod(postMethod);
System.out.println(status + "\n" + postMethod.getResponseBodyAsString());
} finally {
postMethod.releaseConnection();
}
}
分享到:
相关推荐
- Dubbo支持多种通信协议,如RPC(Remote Procedure Call)、HTTP、REST等。默认使用的是高性能的Dubbo协议,基于TCP,实现了对多种序列化方式的支持,如Hessian、Java序列化等。 - 序列化决定了服务间的数据交换...
4. **WebDriver API**:虽然此书发布时Selenium 2.0(包含了WebDriver)尚未正式发布,但可能已经涵盖了WebDriver的基本概念,因为它是Selenium 1.0的一个重要补充,用于更直接地控制浏览器。 5. **测试框架集成**...
JAX-RPC(Java API for XML-based Remote Procedure Calls)是Java平台上的一种早期的Web服务标准,它允许Java应用程序通过XML进行远程过程调用,实现分布式计算。在本话题中,我们将讨论的是一个针对JAX-RPC的Maven...
cmd脚本-bat批处理-清除熊猫内存病毒.zip
cmd-bat-批处理-脚本-打开系统属性.zip
cmd-bat-批处理-脚本-jacksi.zip
该资源为openai-1.59.2-py3-none-any.whl,欢迎下载使用哦!
25年上半年湖师大学位报考附件.zip
基于单片机的系统
cmd-bat-批处理-脚本-文本内容互换.zip
振动压路机振动轮.rar
斩月网络验证是一款完全免费的Windows网络验证,无联网限制,不用担心后门,拓展性极强,无壳,故性能损失为0,发布前已测试过所有功能,无bug,纯JSON请求,易于移植到各个语言使用,数据库完全掌握在你自己手中(最放心),支持保存自定义键值,并且可以自己编写加密方式和加密算法处理收发包返回值(最安全) 无套路 真免费 高效网络验证 功能全面 websocket双向通信 这款验证工具并非商业验证,它的更新与盈利无关。将始终坚守,保持更新,为您提供安全、可靠的验证服务。我明白有些人可能会有疑虑,担心这款新的验证工具是否可靠。但我想说,我尽我所能去优化它,确保它的安全性和有效性。我衷心希望大家能接受,能对这款验证工具保持信心。 特点: 支持5种计费模式,返回值自定义加解密 数据库内容自定义 1:账号登录 2:卡密登录 3:扣点模式 4:扣时模式 5:类似大漠的计费机器扣点模式 支持制定系统防火墙层面规则,关闭端口,封禁IP,杜绝被攻击的可能性 优势:开箱即用,可自定义返回值,自己写插件,性能强,稳定6W同时在线用户 希望这款验证,能满足你的一切需求,节省你的开发时间,您的使用就是对我莫大的支持(请勿用于非法用途)
cmd脚本-bat批处理-测试网络是否通畅.zip
cmd-bat-批处理-脚本-在所有文件夹下建立随机文件.zip
cmd-bat-批处理-脚本-判断光驱是否可用.zip
基于YOLOv5的FPS类游戏自动瞄准系统源码+使用说明.zip 确保可以使用,仅供学习参考,不得用于非法用途。。内容来源于网络分享,如有侵权请联系我删除。
cmd脚本-bat批处理-去掉字符串头所有的0.zip
使用方法:拷贝到Auto CAD的Fonts下
使用方法:拷贝到Auto CAD的Fonts下
使用方法:拷贝到Auto CAD的Fonts下