gojenkins icon indicating copy to clipboard operation
gojenkins copied to clipboard

Jenkins.Init() should return the status code

Open NeonWizard opened this issue 3 years ago • 0 comments
trafficstars

I'm having difficulty connecting to an enterprise Jenkins instance, and can't troubleshoot whether my credentials are invalid or unauthorized, since Jenkins.Init() doesn't tell me the status code, just that it failed.

Suggested change:

j.Version = rsp.Header.Get("X-Jenkins")
if j.Raw == nil || rsp.StatusCode != http.StatusOK {
    return nil, errors.New(fmt.Sprintf("Connection Failed, please verify that the host and credentials are correct. Status Code %d", rsp.StatusCode))
}

Previously suggested by @vperson in https://github.com/bndr/gojenkins/issues/210#issuecomment-808831117

NeonWizard avatar Sep 15 '22 18:09 NeonWizard