added cookie jar

This commit is contained in:
Seshu Kumar Alluvada 2020-03-27 10:32:46 -04:00
parent 5baee01ac5
commit 7790ca6f0f
1 changed files with 8 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package client
import (
"fmt"
"net/http"
"net/http/cookiejar"
"regexp"
"strings"
@ -150,7 +151,13 @@ func newClient(url, userName, passwordOrToken string) (Jenkins, error) {
jenkinsClient.Server = url
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 {
basicAuth = &gojenkins.BasicAuth{Username: userName, Password: passwordOrToken}
} else {