I was using jenkins and accessing urls directly.
eg. http://jenkins.local:8080/job/path_to_file/config.xml
and it used to give me an xml output.
Not the jenkins has an user login functionality. So accessing the same url lands me on the login page. How to have user authentication on Jenkins?
I checked for the apis but nothing suggests anything close to it.
You can use the following method:
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();
}
where requestUrl is the url+config.xml. and HttpRequestInterceptor is an interfatce so you have to create your own class that extends it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.