Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
8ba8078a
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8ba8078a
编写于
5月 08, 2019
作者:
R
runzexia
提交者:
GitHub
5月 08, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #391 from runzexia/reinit-jenkins-
retry init if jenkinsClient == nil
上级
e40dd115
e0f84ab5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
29 deletion
+30
-29
pkg/apis/devops/v1alpha2/register.go
pkg/apis/devops/v1alpha2/register.go
+3
-3
pkg/simple/client/admin_jenkins/jenkins.go
pkg/simple/client/admin_jenkins/jenkins.go
+27
-26
未找到文件。
pkg/apis/devops/v1alpha2/register.go
浏览文件 @
8ba8078a
...
...
@@ -695,7 +695,7 @@ func addWebService(c *restful.Container) error {
Param
(
webservice
.
QueryParameter
(
"limit"
,
"limit count"
)
.
Required
(
false
)
.
DataFormat
(
"limit=%d"
))
.
Returns
(
http
.
StatusOK
,
RespOK
,[]
devops
.
NodeSteps
{})
.
Returns
(
http
.
StatusOK
,
RespOK
,
[]
devops
.
NodeSteps
{})
.
Writes
([]
devops
.
NodeSteps
{}))
// match /blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/nodes/%s/steps/?limit=
...
...
@@ -721,7 +721,7 @@ func addWebService(c *restful.Container) error {
Produces
(
"application/json"
,
"charset=utf-8"
)
.
Doc
(
"Json to Jenkinsfile."
)
.
Reads
(
devops
.
ReqJson
{})
.
Returns
(
http
.
StatusOK
,
RespOK
,
devops
.
NodeSteps
{})
.
Returns
(
http
.
StatusOK
,
RespOK
,
devops
.
NodeSteps
{})
.
Writes
(
devops
.
ResJenkinsfile
{}))
// match /pipeline-model-converter/toJson
...
...
@@ -732,7 +732,7 @@ func addWebService(c *restful.Container) error {
Produces
(
"application/json"
,
"charset=utf-8"
)
.
Doc
(
"Jenkinsfile to Json."
)
.
Reads
(
devops
.
ReqJenkinsfile
{})
.
Returns
(
http
.
StatusOK
,
RespOK
,
devops
.
ResJson
{})
.
Returns
(
http
.
StatusOK
,
RespOK
,
devops
.
ResJson
{})
.
Writes
(
devops
.
ResJson
{}))
// match /git/notifyCommit/?url=
...
...
pkg/simple/client/admin_jenkins/jenkins.go
浏览文件 @
8ba8078a
...
...
@@ -21,7 +21,7 @@ import (
)
var
(
jenkins
ClientOnce
sync
.
Once
jenkins
InitMutex
sync
.
Mutex
jenkinsClient
*
gojenkins
.
Jenkins
jenkinsAdminAddress
string
jenkinsAdminUsername
string
...
...
@@ -41,35 +41,36 @@ func init() {
}
func
Client
()
*
gojenkins
.
Jenkins
{
jenkinsClientOnce
.
Do
(
func
()
{
jenkins
:=
gojenkins
.
CreateJenkins
(
nil
,
jenkinsAdminAddress
,
jenkinsMaxConn
,
jenkinsAdminUsername
,
jenkinsAdminPassword
)
jenkins
,
err
:=
jenkins
.
Init
()
if
err
!=
nil
{
glog
.
Error
(
"failed to connect jenkins"
)
return
}
jenkinsClient
=
jenkins
globalRole
,
err
:=
jenkins
.
GetGlobalRole
(
JenkinsAllUserRoleName
)
if
err
!=
nil
{
glog
.
Error
(
"failed to get jenkins role"
)
}
if
globalRole
==
nil
{
_
,
err
:=
jenkins
.
AddGlobalRole
(
JenkinsAllUserRoleName
,
gojenkins
.
GlobalPermissionIds
{
GlobalRead
:
true
,
if
jenkinsClient
==
nil
{
jenkinsInitMutex
.
Lock
()
defer
jenkinsInitMutex
.
Unlock
()
if
jenkinsClient
==
nil
{
jenkins
:=
gojenkins
.
CreateJenkins
(
nil
,
jenkinsAdminAddress
,
jenkinsMaxConn
,
jenkinsAdminUsername
,
jenkinsAdminPassword
)
jenkins
,
err
:=
jenkins
.
Init
()
if
err
!=
nil
{
glog
.
Errorf
(
"failed to connect jenkins, %+v"
,
err
)
}
globalRole
,
err
:=
jenkins
.
GetGlobalRole
(
JenkinsAllUserRoleName
)
if
err
!=
nil
{
glog
.
Errorf
(
"failed to get jenkins role, %+v"
,
err
)
}
if
globalRole
==
nil
{
_
,
err
:=
jenkins
.
AddGlobalRole
(
JenkinsAllUserRoleName
,
gojenkins
.
GlobalPermissionIds
{
GlobalRead
:
true
,
},
true
)
if
err
!=
nil
{
glog
.
Errorf
(
"failed to create jenkins global role, %+v"
,
err
)
}
}
_
,
err
=
jenkins
.
AddProjectRole
(
JenkinsAllUserRoleName
,
"
\\
n
\\
s*
\\
r"
,
gojenkins
.
ProjectPermissionIds
{
SCMTag
:
true
,
},
true
)
if
err
!=
nil
{
glog
.
Error
(
"failed to create jenkins global role"
)
return
glog
.
Errorf
(
"failed to create jenkins project role, %+v"
,
err
)
}
jenkinsClient
=
jenkins
}
_
,
err
=
jenkins
.
AddProjectRole
(
JenkinsAllUserRoleName
,
"
\\
n
\\
s*
\\
r"
,
gojenkins
.
ProjectPermissionIds
{
SCMTag
:
true
,
},
true
)
if
err
!=
nil
{
glog
.
Error
(
"failed to create jenkins project role"
)
return
}
})
}
return
jenkinsClient
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录