![](/img/trans.png)
[英]HDFS access from remote host through Java API, user authentication
[英]User Authentication on Jenkins through java
我正在使用jenkins并直接访问url。
例如。 http://jenkins.local:8080/job/path_to_file/config.xml
它曾经给我一个xml输出。
不是jenkins具有用户登录功能。 因此,访问相同的URL使我进入登录页面。 如何在Jenkins上进行用户身份验证?
我检查了api,但没有任何暗示。
您可以使用以下方法:
public InputStream processPostRequest(String requestUrl) {
DefaultHttpClient client = null;
client = createHttpClient("admin", "pas");
HttpEntity entity = null;
BasicHttpContext context = null;
context = createHttpContext();
client.addRequestInterceptor(new HttpRequestInterceptor(), 0);
HttpGet get = new HttpGet(requestUrl);
try {
// Execute your request with the given context
HttpResponse response = client.execute(get, context);
entity = response.getEntity();
} catch (IOException e) {
e.printStackTrace();
}
return entity..getContent();
}
其中requestUrl是url + config.xml。 HttpRequestInterceptor是一个接口,因此您必须创建自己的扩展它的类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.