Skip to content

Commit

Permalink
Allow insecurely connecting to a host
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Duchesne committed Jun 20, 2019
1 parent 1995888 commit 1357b7d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ require (
gopkg.in/yaml.v2 v2.2.2
)

replace github.com/bndr/gojenkins => github.com/julienduchesne/gojenkins v2.0.0+incompatible
replace github.com/bndr/gojenkins => github.com/julienduchesne/gojenkins v2.0.1+incompatible
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/julienduchesne/gojenkins v2.0.0+incompatible h1:/XwAEsQjBa4z4zJ6ADtN41jLDvJ/Oxsh5S3JAP29SJM=
github.com/julienduchesne/gojenkins v2.0.0+incompatible/go.mod h1:vyTgrnBY+eN7w3FULQEfdrbSMecftCpXw9XGQmF76dk=
github.com/julienduchesne/gojenkins v2.0.1+incompatible h1:EEsEPWaysnZyN+RYkLgKuF09Me50yhD5/nDsDAgr86I=
github.com/julienduchesne/gojenkins v2.0.1+incompatible/go.mod h1:vyTgrnBY+eN7w3FULQEfdrbSMecftCpXw9XGQmF76dk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
Expand Down
15 changes: 8 additions & 7 deletions targets/jenkins.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/url"

"github.com/aws/aws-sdk-go/aws"
log "github.com/sirupsen/logrus"

"github.com/bndr/gojenkins"
Expand All @@ -16,9 +17,9 @@ const credentialsDomain = "_"
type JenkinsTarget struct {
Base `mapstructure:",squash"`

CredentialsID *string `mapstructure:"credentials_id"`
URL string
SecureConnection bool `mapstructure:"secure_connections"`
CredentialsID *string `mapstructure:"credentials_id"`
URL string
InsecureConnection bool `mapstructure:"insecure_connection"`

client *gojenkins.Jenkins
credentialsManager *gojenkins.CredentialsManager
Expand Down Expand Up @@ -48,14 +49,14 @@ func (jenkins *JenkinsTarget) Initialize(allCredentials []credentials.Credential
jenkins.loginCredentials = credentials
}
}
options := &gojenkins.JenkinsOptions{SslVerify: aws.Bool(!jenkins.InsecureConnection)}
if jenkins.loginCredentials != nil {
auth := jenkins.loginCredentials.(*credentials.UsernamePasswordCredentials)
jenkins.client = gojenkins.CreateJenkins(nil, jenkins.URL, auth.Username, auth.Password)
} else {
jenkins.client = gojenkins.CreateJenkins(nil, jenkins.URL)
options.Username = &auth.Username
options.Password = &auth.Password
}
jenkins.client = gojenkins.CreateJenkinsWithOptions(jenkins.URL, options)

jenkins.client.Requester.SslVerify = jenkins.SecureConnection
jenkins.client.Init()
jenkins.credentialsManager = &gojenkins.CredentialsManager{
J: jenkins.client,
Expand Down

0 comments on commit 1357b7d

Please sign in to comment.