jenkinsci / jenkinsci/java-client-api

Exception: org.apache.http.client.HttpResponseException: Forbidden error

Open
#319 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
913
Forks
466
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm using this jenkins client to trigger jobs and get the console output. But, since yesterday I'm getting the error
"**Exception: org.apache.http.client.HttpResponseException: Forbidden**" exception when I trigger a job using my existing credentials.

I'm able to fetch details of the job but not trigger a build using the same credentials.

Here's the sample snippet of code i'm using for triggering a job and fetching details from a job.

Triggering a job (Not working)

`String uri = "http://A.B.C.D:PORT/jenkins";
String username = "xyz";
String password = "xyz";
JenkinsServer js = null;

try {
js = new JenkinsServer(new URI(uri), username, password);
} catch(Exception e) {
System.out.println("Exception: " + e);
}
BuildWithDetails buildDetails = null;

try {
JenkinsTriggerHelper jsHelper = new JenkinsTriggerHelper(js);
buildDetails = jsHelper.triggerJobAndWaitUntilFinished("dev-3");
} catch(Exception e) {
System.out.println("Exception: " + e);
}

String consoleOutput = "";
System.out.println("Build details: " + buildDetails.getResult());
System.out.println("Build duration: " + buildDetails.getDuration());
//System.out.println("Build logs: " + buildDetails.getConsoleOutputText());

System.out.println(getBuildInfo(buildDetails.getConsoleOutputText()));
`

I believe it is something to do with authorizations for a user but as far as I know there haven't been any upgrades to the jenkins server we're using.

Any help is appreciated.

Thank you!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.