Why do I get 302 HTTP status codes when I run my Scala test on Jenkins instead of 204? Why do I get 302 HTTP status codes when I run my Scala test on Jenkins instead of 204? jenkins jenkins

Why do I get 302 HTTP status codes when I run my Scala test on Jenkins instead of 204?


It's not completely clear from your description, but it seems likely that the issue is a matter of 3xx redirections being followed automatically in some cases and not in others.

For example, when you use 'curl', you include the -L option so that 3xx redirections are followed automatically, which is what you want to happen.

Therefore, in your Java code, it is quite possible that your laptop is also following redirections, whereas you CI build server is not, due to it being unspecified.

Apache Http Client should also, by default, follow redirections.

If you'll forgive the plug, I have written an alternative HTTP client based on Java's URLConnection (called Bee Client - please note that it's still at a beta release though).

Because URLConnection will follow redirections by default, that's also what Bee Client does.

val httpClient = new HttpClientval response: Response = httpClient.get("https://admin-platform.company.com:443/usergroups/rest/usergroups")

The status code is included in the response and it will be a 2xx if there was no error.

There is an option to disable redirections, but it sounds like you don't need this.


This might be the answer. We are doing an HttpPost in our login/authentication:

https://stackoverflow.com/a/5170468/1759990


My coworker researched the problem. The tests were running perfect on another environment (we have several: qa, staging, production, demo, etc.). It looks as if the problem was the QA server had a self-signed SSL certificate which Jenkins was not accepting, or the client couldn't accept. I probably had manually accepted the cert on my local workstation, which is why the tests ran locally.

The fix would be for our IT department to use a real cert, as the other environment does.