bndr/gojenkins

Jenkins.Init() should return the status code

NeonWizard opened this issue · 0 comments

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 #210 (comment)