未验证 提交 3af400e7 编写于 作者: R runzexia 提交者: GitHub

Merge pull request #408 from soulseen/master

fix init jenkins
......@@ -33,6 +33,7 @@ import (
"kubesphere.io/kubesphere/pkg/models/devops"
logging "kubesphere.io/kubesphere/pkg/models/log"
"kubesphere.io/kubesphere/pkg/signals"
"kubesphere.io/kubesphere/pkg/simple/client/admin_jenkins"
"kubesphere.io/kubesphere/pkg/simple/client/devops_mysql"
"log"
"net/http"
......@@ -99,7 +100,8 @@ func Run(s *options.ServerRunOptions) error {
}
func initializeAdminJenkins() {
devops.PreCheckJenkins()
devops.JenkinsInit()
admin_jenkins.Client()
}
func initializeDevOpsDatabase() {
......
......@@ -37,8 +37,8 @@ const channelMaxCapacity = 100
var jenkins *gojenkins.Jenkins
func PreCheckJenkins() {
jenkins = admin_jenkins.Client()
func JenkinsInit() {
jenkins = admin_jenkins.GetJenkins()
}
func GetPipeline(projectName, pipelineName string, req *http.Request) ([]byte, error) {
......
......@@ -40,12 +40,17 @@ func init() {
flag.IntVar(&jenkinsMaxConn, "jenkins-max-conn", 20, "max conn to jenkins")
}
func GetJenkins() *gojenkins.Jenkins {
jenkins := gojenkins.CreateJenkins(nil, jenkinsAdminAddress, jenkinsMaxConn, jenkinsAdminUsername, jenkinsAdminPassword)
return jenkins
}
func Client() *gojenkins.Jenkins {
if jenkinsClient == nil {
jenkinsInitMutex.Lock()
defer jenkinsInitMutex.Unlock()
if jenkinsClient == nil {
jenkins := gojenkins.CreateJenkins(nil, jenkinsAdminAddress, jenkinsMaxConn, jenkinsAdminUsername, jenkinsAdminPassword)
jenkins := GetJenkins()
jenkins, err := jenkins.Init()
if err != nil {
glog.Errorf("failed to connect jenkins, %+v", err)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册