added cookie jar
This commit is contained in:
		
							parent
							
								
									5baee01ac5
								
							
						
					
					
						commit
						7790ca6f0f
					
				|  | @ -3,6 +3,7 @@ package client | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"net/http" | 	"net/http" | ||||||
|  | 	"net/http/cookiejar" | ||||||
| 	"regexp" | 	"regexp" | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
|  | @ -150,7 +151,13 @@ func newClient(url, userName, passwordOrToken string) (Jenkins, error) { | ||||||
| 	jenkinsClient.Server = url | 	jenkinsClient.Server = url | ||||||
| 
 | 
 | ||||||
| 	var basicAuth *gojenkins.BasicAuth | 	var basicAuth *gojenkins.BasicAuth | ||||||
| 	httpClient := http.DefaultClient | 	jar, err := cookiejar.New(nil) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, errors.Wrap(err, "couldn't create a cookie jar") | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	httpClient := &http.Client{Jar: jar} | ||||||
|  | 
 | ||||||
| 	if len(userName) > 0 && len(passwordOrToken) > 0 { | 	if len(userName) > 0 && len(passwordOrToken) > 0 { | ||||||
| 		basicAuth = &gojenkins.BasicAuth{Username: userName, Password: passwordOrToken} | 		basicAuth = &gojenkins.BasicAuth{Username: userName, Password: passwordOrToken} | ||||||
| 	} else { | 	} else { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue