Always send basic auth in jenkins input (#5329)

This commit is contained in:
Daniel Nelson 2019-01-23 14:17:57 -08:00 committed by GitHub
parent aabb60dfec
commit d1610d50e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 31 deletions

View File

@ -15,10 +15,10 @@ This plugin does not require a plugin on jenkins and it makes use of Jenkins API
## Set response_timeout ## Set response_timeout
response_timeout = "5s" response_timeout = "5s"
## Optional SSL Config ## Optional TLS Config
# ssl_ca = /path/to/cafile # tls_ca = "/etc/telegraf/ca.pem"
# ssl_cert = /path/to/certfile # tls_cert = "/etc/telegraf/cert.pem"
# ssl_key = /path/to/keyfile # tls_key = "/etc/telegraf/key.pem"
## Use SSL but skip chain & host verification ## Use SSL but skip chain & host verification
# insecure_skip_verify = false # insecure_skip_verify = false

View File

@ -33,8 +33,7 @@ func (c *client) init() error {
if err != nil { if err != nil {
return err return err
} }
if c.username != "" && c.password != "" { if c.username != "" || c.password != "" {
// set auth
req.SetBasicAuth(c.username, c.password) req.SetBasicAuth(c.username, c.password)
} }
resp, err := c.httpClient.Do(req) resp, err := c.httpClient.Do(req)
@ -123,10 +122,11 @@ func createGetRequest(url string, username, password string, sessionCookie *http
if err != nil { if err != nil {
return nil, err return nil, err
} }
if username != "" || password != "" {
req.SetBasicAuth(username, password)
}
if sessionCookie != nil { if sessionCookie != nil {
req.AddCookie(sessionCookie) req.AddCookie(sessionCookie)
} else if username != "" && password != "" {
req.SetBasicAuth(username, password)
} }
req.Header.Add("Accept", "application/json") req.Header.Add("Accept", "application/json")
return req, nil return req, nil

View File

@ -51,10 +51,10 @@ const sampleConfig = `
## Set response_timeout ## Set response_timeout
response_timeout = "5s" response_timeout = "5s"
## Optional SSL Config ## Optional TLS Config
# ssl_ca = /path/to/cafile # tls_ca = "/etc/telegraf/ca.pem"
# ssl_cert = /path/to/certfile # tls_cert = "/etc/telegraf/cert.pem"
# ssl_key = /path/to/keyfile # tls_key = "/etc/telegraf/key.pem"
## Use SSL but skip chain & host verification ## Use SSL but skip chain & host verification
# insecure_skip_verify = false # insecure_skip_verify = false