Always send basic auth in jenkins input (#5329)
This commit is contained in:
parent
aabb60dfec
commit
d1610d50e6
|
@ -9,44 +9,44 @@ This plugin does not require a plugin on jenkins and it makes use of Jenkins API
|
||||||
```toml
|
```toml
|
||||||
## The Jenkins URL
|
## The Jenkins URL
|
||||||
url = "http://my-jenkins-instance:8080"
|
url = "http://my-jenkins-instance:8080"
|
||||||
# username = "admin"
|
# username = "admin"
|
||||||
# password = "admin"
|
# password = "admin"
|
||||||
|
|
||||||
## 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
|
||||||
|
|
||||||
## Optional Max Job Build Age filter
|
## Optional Max Job Build Age filter
|
||||||
## Default 1 hour, ignore builds older than max_build_age
|
## Default 1 hour, ignore builds older than max_build_age
|
||||||
# max_build_age = "1h"
|
# max_build_age = "1h"
|
||||||
|
|
||||||
## Optional Sub Job Depth filter
|
## Optional Sub Job Depth filter
|
||||||
## Jenkins can have unlimited layer of sub jobs
|
## Jenkins can have unlimited layer of sub jobs
|
||||||
## This config will limit the layers of pulling, default value 0 means
|
## This config will limit the layers of pulling, default value 0 means
|
||||||
## unlimited pulling until no more sub jobs
|
## unlimited pulling until no more sub jobs
|
||||||
# max_subjob_depth = 0
|
# max_subjob_depth = 0
|
||||||
|
|
||||||
## Optional Sub Job Per Layer
|
## Optional Sub Job Per Layer
|
||||||
## In workflow-multibranch-plugin, each branch will be created as a sub job.
|
## In workflow-multibranch-plugin, each branch will be created as a sub job.
|
||||||
## This config will limit to call only the lasted branches in each layer,
|
## This config will limit to call only the lasted branches in each layer,
|
||||||
## empty will use default value 10
|
## empty will use default value 10
|
||||||
# max_subjob_per_layer = 10
|
# max_subjob_per_layer = 10
|
||||||
|
|
||||||
## Jobs to exclude from gathering
|
## Jobs to exclude from gathering
|
||||||
# job_exclude = [ "job1", "job2/subjob1/subjob2", "job3/*"]
|
# job_exclude = [ "job1", "job2/subjob1/subjob2", "job3/*"]
|
||||||
|
|
||||||
## Nodes to exclude from gathering
|
## Nodes to exclude from gathering
|
||||||
# node_exclude = [ "node1", "node2" ]
|
# node_exclude = [ "node1", "node2" ]
|
||||||
|
|
||||||
## Worker pool for jenkins plugin only
|
## Worker pool for jenkins plugin only
|
||||||
## Empty this field will use default value 5
|
## Empty this field will use default value 5
|
||||||
# max_connections = 5
|
# max_connections = 5
|
||||||
```
|
```
|
||||||
|
|
||||||
### Metrics:
|
### Metrics:
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -45,44 +45,44 @@ type Jenkins struct {
|
||||||
const sampleConfig = `
|
const sampleConfig = `
|
||||||
## The Jenkins URL
|
## The Jenkins URL
|
||||||
url = "http://my-jenkins-instance:8080"
|
url = "http://my-jenkins-instance:8080"
|
||||||
# username = "admin"
|
# username = "admin"
|
||||||
# password = "admin"
|
# password = "admin"
|
||||||
|
|
||||||
## 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
|
||||||
|
|
||||||
## Optional Max Job Build Age filter
|
## Optional Max Job Build Age filter
|
||||||
## Default 1 hour, ignore builds older than max_build_age
|
## Default 1 hour, ignore builds older than max_build_age
|
||||||
# max_build_age = "1h"
|
# max_build_age = "1h"
|
||||||
|
|
||||||
## Optional Sub Job Depth filter
|
## Optional Sub Job Depth filter
|
||||||
## Jenkins can have unlimited layer of sub jobs
|
## Jenkins can have unlimited layer of sub jobs
|
||||||
## This config will limit the layers of pulling, default value 0 means
|
## This config will limit the layers of pulling, default value 0 means
|
||||||
## unlimited pulling until no more sub jobs
|
## unlimited pulling until no more sub jobs
|
||||||
# max_subjob_depth = 0
|
# max_subjob_depth = 0
|
||||||
|
|
||||||
## Optional Sub Job Per Layer
|
## Optional Sub Job Per Layer
|
||||||
## In workflow-multibranch-plugin, each branch will be created as a sub job.
|
## In workflow-multibranch-plugin, each branch will be created as a sub job.
|
||||||
## This config will limit to call only the lasted branches in each layer,
|
## This config will limit to call only the lasted branches in each layer,
|
||||||
## empty will use default value 10
|
## empty will use default value 10
|
||||||
# max_subjob_per_layer = 10
|
# max_subjob_per_layer = 10
|
||||||
|
|
||||||
## Jobs to exclude from gathering
|
## Jobs to exclude from gathering
|
||||||
# job_exclude = [ "job1", "job2/subjob1/subjob2", "job3/*"]
|
# job_exclude = [ "job1", "job2/subjob1/subjob2", "job3/*"]
|
||||||
|
|
||||||
## Nodes to exclude from gathering
|
## Nodes to exclude from gathering
|
||||||
# node_exclude = [ "node1", "node2" ]
|
# node_exclude = [ "node1", "node2" ]
|
||||||
|
|
||||||
## Worker pool for jenkins plugin only
|
## Worker pool for jenkins plugin only
|
||||||
## Empty this field will use default value 5
|
## Empty this field will use default value 5
|
||||||
# max_connections = 5
|
# max_connections = 5
|
||||||
`
|
`
|
||||||
|
|
||||||
// measurement
|
// measurement
|
||||||
|
|
Loading…
Reference in New Issue