Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2020fengziyang
kubesphere
提交
f22e8ea9
K
kubesphere
项目概览
2020fengziyang
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
1
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,发现更多精彩内容 >>
未验证
提交
f22e8ea9
编写于
8月 27, 2019
作者:
K
KubeSphere CI Bot
提交者:
GitHub
8月 27, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #670 from runzexia/bitbucket-support
Pipeline Support Bitbucket Scm
上级
c6440ec6
31bbbe0c
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
688 addition
and
377 deletion
+688
-377
pkg/apis/devops/v1alpha2/register.go
pkg/apis/devops/v1alpha2/register.go
+19
-0
pkg/apiserver/devops/devops.go
pkg/apiserver/devops/devops.go
+26
-0
pkg/models/devops/devops.go
pkg/models/devops/devops.go
+25
-1
pkg/models/devops/json.go
pkg/models/devops/json.go
+18
-0
pkg/models/devops/project_pipeline.go
pkg/models/devops/project_pipeline.go
+572
-371
pkg/models/devops/project_pipeline_test.go
pkg/models/devops/project_pipeline_test.go
+26
-5
pkg/models/devops/urlconfig.go
pkg/models/devops/urlconfig.go
+2
-0
未找到文件。
pkg/apis/devops/v1alpha2/register.go
浏览文件 @
f22e8ea9
...
@@ -350,6 +350,25 @@ The last one is encrypted info, such as the password of the username-password ty
...
@@ -350,6 +350,25 @@ The last one is encrypted info, such as the password of the username-password ty
Returns
(
http
.
StatusOK
,
RespOK
,
[]
devops
.
SCMOrg
{})
.
Returns
(
http
.
StatusOK
,
RespOK
,
[]
devops
.
SCMOrg
{})
.
Writes
([]
devops
.
SCMOrg
{}))
Writes
([]
devops
.
SCMOrg
{}))
// match "/blue/rest/organizations/jenkins/scm/%s/servers/"
webservice
.
Route
(
webservice
.
GET
(
"/scms/{scm}/servers"
)
.
To
(
devopsapi
.
GetSCMServers
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsScmTag
})
.
Doc
(
"List all servers in the jenkins."
)
.
Param
(
webservice
.
PathParameter
(
"scm"
,
"The ID of the source configuration management (SCM)."
))
.
Returns
(
http
.
StatusOK
,
RespOK
,
[]
devops
.
SCMServer
{})
.
Writes
([]
devops
.
SCMServer
{}))
// match "/blue/rest/organizations/jenkins/scm/%s/servers/"
webservice
.
Route
(
webservice
.
POST
(
"/scms/{scm}/servers"
)
.
To
(
devopsapi
.
CreateSCMServers
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsScmTag
})
.
Doc
(
"Create scm server in the jenkins."
)
.
Param
(
webservice
.
PathParameter
(
"scm"
,
"The ID of the source configuration management (SCM)."
))
.
Reads
(
devops
.
CreateScmServerReq
{})
.
Returns
(
http
.
StatusOK
,
RespOK
,
devops
.
SCMServer
{})
.
Writes
(
devops
.
SCMServer
{}))
// match "/blue/rest/organizations/jenkins/scm/{scm}/organizations/{organization}/repositories/?credentialId=&pageNumber&pageSize="
// match "/blue/rest/organizations/jenkins/scm/{scm}/organizations/{organization}/repositories/?credentialId=&pageNumber&pageSize="
webservice
.
Route
(
webservice
.
GET
(
"/scms/{scm}/organizations/{organization}/repositories"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/scms/{scm}/organizations/{organization}/repositories"
)
.
To
(
devopsapi
.
GetOrgRepo
)
.
To
(
devopsapi
.
GetOrgRepo
)
.
...
...
pkg/apiserver/devops/devops.go
浏览文件 @
f22e8ea9
...
@@ -141,6 +141,32 @@ func GetStepLog(req *restful.Request, resp *restful.Response) {
...
@@ -141,6 +141,32 @@ func GetStepLog(req *restful.Request, resp *restful.Response) {
resp
.
Write
(
res
)
resp
.
Write
(
res
)
}
}
func
GetSCMServers
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
scmId
:=
req
.
PathParameter
(
"scm"
)
res
,
err
:=
devops
.
GetSCMServers
(
scmId
,
req
.
Request
)
if
err
!=
nil
{
parseErr
(
err
,
resp
)
return
}
resp
.
Header
()
.
Set
(
restful
.
HEADER_ContentType
,
restful
.
MIME_JSON
)
resp
.
Write
(
res
)
}
func
CreateSCMServers
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
scmId
:=
req
.
PathParameter
(
"scm"
)
res
,
err
:=
devops
.
CreateSCMServers
(
scmId
,
req
.
Request
)
if
err
!=
nil
{
parseErr
(
err
,
resp
)
return
}
resp
.
Header
()
.
Set
(
restful
.
HEADER_ContentType
,
restful
.
MIME_JSON
)
resp
.
Write
(
res
)
}
func
Validate
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
Validate
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
scmId
:=
req
.
PathParameter
(
"scm"
)
scmId
:=
req
.
PathParameter
(
"scm"
)
...
...
pkg/models/devops/devops.go
浏览文件 @
f22e8ea9
...
@@ -135,6 +135,30 @@ func GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, req *ht
...
@@ -135,6 +135,30 @@ func GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, req *ht
}
}
func
GetSCMServers
(
scmId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetSCMServersUrl
,
scmId
)
log
.
Info
(
"Jenkins-url: "
+
baseUrl
)
req
.
Method
=
http
.
MethodGet
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
err
}
return
resBody
,
err
}
func
CreateSCMServers
(
scmId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
CreateSCMServersUrl
,
scmId
)
log
.
Info
(
"Jenkins-url: "
+
baseUrl
)
req
.
Method
=
http
.
MethodPost
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
err
}
return
resBody
,
err
}
func
Validate
(
scmId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
func
Validate
(
scmId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
ValidateUrl
,
scmId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
ValidateUrl
,
scmId
)
log
.
Info
(
"Jenkins-url: "
+
baseUrl
)
log
.
Info
(
"Jenkins-url: "
+
baseUrl
)
...
@@ -731,7 +755,7 @@ func jenkinsClient(baseUrl string, req *http.Request) ([]byte, http.Header, erro
...
@@ -731,7 +755,7 @@ func jenkinsClient(baseUrl string, req *http.Request) ([]byte, http.Header, erro
log
.
Errorf
(
"%+v"
,
string
(
resBody
))
log
.
Errorf
(
"%+v"
,
string
(
resBody
))
jkerr
:=
new
(
JkError
)
jkerr
:=
new
(
JkError
)
jkerr
.
Code
=
resp
.
StatusCode
jkerr
.
Code
=
resp
.
StatusCode
jkerr
.
Message
=
http
.
StatusText
(
resp
.
StatusCode
)
jkerr
.
Message
=
string
(
resBody
)
return
nil
,
nil
,
jkerr
return
nil
,
nil
,
jkerr
}
}
...
...
pkg/models/devops/json.go
浏览文件 @
f22e8ea9
...
@@ -260,6 +260,19 @@ type SCMOrg struct {
...
@@ -260,6 +260,19 @@ type SCMOrg struct {
Name
string
`json:"name,omitempty" description:"organization name"`
Name
string
`json:"name,omitempty" description:"organization name"`
}
}
type
SCMServer
struct
{
Class
string
`json:"_class,omitempty" description:"It’s a fully qualified name and is an identifier of the producer of this resource's capability."`
Links
struct
{
Self
struct
{
Class
string
`json:"_class,omitempty" description:"It’s a fully qualified name and is an identifier of the producer of this resource's capability."`
Href
string
`json:"href,omitempty" description:"self url in api"`
}
`json:"self,omitempty" description:"scm server self info"`
}
`json:"_links,omitempty" description:"references the reachable path to this resource"`
ID
string
`json:"id,omitempty" description:"server id of scm server"`
Name
string
`json:"name,omitempty" description:"name of scm server"`
ApiURL
string
`json:"apiUrl,omitempty" description:"url of scm server"`
}
// GetOrgRepo
// GetOrgRepo
type
OrgRepo
struct
{
type
OrgRepo
struct
{
Class
string
`json:"_class,omitempty" description:"It’s a fully qualified name and is an identifier of the producer of this resource's capability."`
Class
string
`json:"_class,omitempty" description:"It’s a fully qualified name and is an identifier of the producer of this resource's capability."`
...
@@ -721,6 +734,11 @@ type CheckPlayload struct {
...
@@ -721,6 +734,11 @@ type CheckPlayload struct {
Abort
bool
`json:"abort,omitempty" description:"abort or not"`
Abort
bool
`json:"abort,omitempty" description:"abort or not"`
}
}
type
CreateScmServerReq
struct
{
Name
string
`json:"name,omitempty" description:"name of scm server"`
ApiURL
string
`json:"apiUrl,omitempty" description:"url of scm server"`
}
type
CheckPlayloadParameters
struct
{
type
CheckPlayloadParameters
struct
{
Name
string
`json:"name,omitempty" description:"name"`
Name
string
`json:"name,omitempty" description:"name"`
Value
string
`json:"value,omitempty" description:"value"`
Value
string
`json:"value,omitempty" description:"value"`
...
...
pkg/models/devops/project_pipeline.go
浏览文件 @
f22e8ea9
此差异已折叠。
点击以展开。
pkg/models/devops/project_pipeline_test.go
浏览文件 @
f22e8ea9
...
@@ -110,7 +110,7 @@ func Test_NoScmPipelineConfig_Param(t *testing.T) {
...
@@ -110,7 +110,7 @@ func Test_NoScmPipelineConfig_Param(t *testing.T) {
Name
:
""
,
Name
:
""
,
Description
:
"for test"
,
Description
:
"for test"
,
Jenkinsfile
:
"node{echo 'hello'}"
,
Jenkinsfile
:
"node{echo 'hello'}"
,
Parameters
:
[]
*
Parameter
{
Parameters
:
&
Parameters
{
&
Parameter
{
&
Parameter
{
Name
:
"d"
,
Name
:
"d"
,
DefaultValue
:
"a
\n
b"
,
DefaultValue
:
"a
\n
b"
,
...
@@ -123,7 +123,7 @@ func Test_NoScmPipelineConfig_Param(t *testing.T) {
...
@@ -123,7 +123,7 @@ func Test_NoScmPipelineConfig_Param(t *testing.T) {
Name
:
""
,
Name
:
""
,
Description
:
"for test"
,
Description
:
"for test"
,
Jenkinsfile
:
"node{echo 'hello'}"
,
Jenkinsfile
:
"node{echo 'hello'}"
,
Parameters
:
[]
*
Parameter
{
Parameters
:
&
Parameters
{
&
Parameter
{
&
Parameter
{
Name
:
"a"
,
Name
:
"a"
,
DefaultValue
:
"abc"
,
DefaultValue
:
"abc"
,
...
@@ -355,7 +355,28 @@ func Test_MultiBranchPipelineConfig_Source(t *testing.T) {
...
@@ -355,7 +355,28 @@ func Test_MultiBranchPipelineConfig_Source(t *testing.T) {
ApiUri
:
"https://api.github.com"
,
ApiUri
:
"https://api.github.com"
,
DiscoverBranches
:
1
,
DiscoverBranches
:
1
,
DiscoverPRFromOrigin
:
2
,
DiscoverPRFromOrigin
:
2
,
DiscoverPRFromForks
:
&
GithubDiscoverPRFromForks
{
DiscoverPRFromForks
:
&
DiscoverPRFromForks
{
Strategy
:
1
,
Trust
:
1
,
},
},
},
&
MultiBranchPipeline
{
Name
:
""
,
Description
:
"for test"
,
ScriptPath
:
"Jenkinsfile"
,
SourceType
:
"bitbucket_server"
,
TimerTrigger
:
&
TimerTrigger
{
Interval
:
"12345566"
,
},
BitbucketServerSource
:
&
BitbucketServerSource
{
Owner
:
"kubesphere"
,
Repo
:
"devops"
,
CredentialId
:
"github"
,
ApiUri
:
"https://api.github.com"
,
DiscoverBranches
:
1
,
DiscoverPRFromOrigin
:
2
,
DiscoverPRFromForks
:
&
DiscoverPRFromForks
{
Strategy
:
1
,
Strategy
:
1
,
Trust
:
1
,
Trust
:
1
,
},
},
...
@@ -439,7 +460,7 @@ func Test_MultiBranchPipelineCloneConfig(t *testing.T) {
...
@@ -439,7 +460,7 @@ func Test_MultiBranchPipelineCloneConfig(t *testing.T) {
ApiUri
:
"https://api.github.com"
,
ApiUri
:
"https://api.github.com"
,
DiscoverBranches
:
1
,
DiscoverBranches
:
1
,
DiscoverPRFromOrigin
:
2
,
DiscoverPRFromOrigin
:
2
,
DiscoverPRFromForks
:
&
Github
DiscoverPRFromForks
{
DiscoverPRFromForks
:
&
DiscoverPRFromForks
{
Strategy
:
1
,
Strategy
:
1
,
Trust
:
1
,
Trust
:
1
,
},
},
...
@@ -496,7 +517,7 @@ func Test_MultiBranchPipelineRegexFilter(t *testing.T) {
...
@@ -496,7 +517,7 @@ func Test_MultiBranchPipelineRegexFilter(t *testing.T) {
ApiUri
:
"https://api.github.com"
,
ApiUri
:
"https://api.github.com"
,
DiscoverBranches
:
1
,
DiscoverBranches
:
1
,
DiscoverPRFromOrigin
:
2
,
DiscoverPRFromOrigin
:
2
,
DiscoverPRFromForks
:
&
Github
DiscoverPRFromForks
{
DiscoverPRFromForks
:
&
DiscoverPRFromForks
{
Strategy
:
1
,
Strategy
:
1
,
Trust
:
1
,
Trust
:
1
,
},
},
...
...
pkg/models/devops/urlconfig.go
浏览文件 @
f22e8ea9
...
@@ -44,6 +44,8 @@ const (
...
@@ -44,6 +44,8 @@ const (
CheckPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/%s/"
CheckPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/%s/"
GetBranchNodeStepsUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/?"
GetBranchNodeStepsUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/?"
GetNodeStepsUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/?"
GetNodeStepsUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/?"
GetSCMServersUrl
=
"/blue/rest/organizations/jenkins/scm/%s/servers/"
CreateSCMServersUrl
=
"/blue/rest/organizations/jenkins/scm/%s/servers/"
ValidateUrl
=
"/blue/rest/organizations/jenkins/scm/%s/validate"
ValidateUrl
=
"/blue/rest/organizations/jenkins/scm/%s/validate"
GetSCMOrgUrl
=
"/blue/rest/organizations/jenkins/scm/%s/organizations/?"
GetSCMOrgUrl
=
"/blue/rest/organizations/jenkins/scm/%s/organizations/?"
GetOrgRepoUrl
=
"/blue/rest/organizations/jenkins/scm/%s/organizations/%s/repositories/?"
GetOrgRepoUrl
=
"/blue/rest/organizations/jenkins/scm/%s/organizations/%s/repositories/?"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录