Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
52b63f5e
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,发现更多精彩内容 >>
未验证
提交
52b63f5e
编写于
5月 08, 2019
作者:
Z
Zhuxiaoyang
提交者:
GitHub
5月 08, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update post run pipeline
Signed-off-by:
N
soulseen
<
sunzhu@yunify.com
>
上级
3aba5b15
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
46 addition
and
7 deletion
+46
-7
pkg/apis/devops/v1alpha2/register.go
pkg/apis/devops/v1alpha2/register.go
+13
-2
pkg/apiserver/devops/devops.go
pkg/apiserver/devops/devops.go
+16
-2
pkg/models/devops/devops.go
pkg/models/devops/devops.go
+15
-2
pkg/models/devops/urlconfig.go
pkg/models/devops/urlconfig.go
+2
-1
未找到文件。
pkg/apis/devops/v1alpha2/register.go
浏览文件 @
52b63f5e
...
...
@@ -573,9 +573,9 @@ func addWebService(c *restful.Container) error {
// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{}/runs/
webservice
.
Route
(
webservice
.
POST
(
"/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/run"
)
.
To
(
devopsapi
.
RunPipeline
)
.
To
(
devopsapi
.
Run
Branch
Pipeline
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
tags
)
.
Doc
(
"
Get pipeline artifacts
."
)
.
Doc
(
"
Run pipeline
."
)
.
Reads
(
devops
.
RunPayload
{})
.
Param
(
webservice
.
PathParameter
(
"projectName"
,
"devops project name"
))
.
Param
(
webservice
.
PathParameter
(
"pipelineName"
,
"pipeline name"
))
.
...
...
@@ -583,6 +583,17 @@ func addWebService(c *restful.Container) error {
Returns
(
http
.
StatusOK
,
RespOK
,
devops
.
QueuedBlueRun
{})
.
Writes
(
devops
.
QueuedBlueRun
{}))
// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/
webservice
.
Route
(
webservice
.
POST
(
"/devops/{projectName}/pipelines/{pipelineName}/run"
)
.
To
(
devopsapi
.
RunPipeline
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
tags
)
.
Doc
(
"Run pipeline."
)
.
Reads
(
devops
.
RunPayload
{})
.
Param
(
webservice
.
PathParameter
(
"projectName"
,
"devops project name"
))
.
Param
(
webservice
.
PathParameter
(
"pipelineName"
,
"pipeline name"
))
.
Returns
(
http
.
StatusOK
,
RespOK
,
devops
.
QueuedBlueRun
{})
.
Writes
(
devops
.
QueuedBlueRun
{}))
// match /pipeline_status/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/?limit=
webservice
.
Route
(
webservice
.
GET
(
"/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/status"
)
.
To
(
devopsapi
.
GetBranchStepsStatus
)
.
...
...
pkg/apiserver/devops/devops.go
浏览文件 @
52b63f5e
...
...
@@ -359,12 +359,26 @@ func ScanBranch(req *restful.Request, resp *restful.Response) {
resp
.
Write
(
res
)
}
func
RunPipeline
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
Run
Branch
Pipeline
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
projectName
:=
req
.
PathParameter
(
"projectName"
)
pipelineName
:=
req
.
PathParameter
(
"pipelineName"
)
branchName
:=
req
.
PathParameter
(
"branchName"
)
res
,
err
:=
devops
.
RunPipeline
(
projectName
,
pipelineName
,
branchName
,
req
.
Request
)
res
,
err
:=
devops
.
RunBranchPipeline
(
projectName
,
pipelineName
,
branchName
,
req
.
Request
)
if
err
!=
nil
{
parseErr
(
err
,
resp
)
return
}
resp
.
Header
()
.
Set
(
restful
.
HEADER_ContentType
,
restful
.
MIME_JSON
)
resp
.
Write
(
res
)
}
func
RunPipeline
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
projectName
:=
req
.
PathParameter
(
"projectName"
)
pipelineName
:=
req
.
PathParameter
(
"pipelineName"
)
res
,
err
:=
devops
.
RunPipeline
(
projectName
,
pipelineName
,
req
.
Request
)
if
err
!=
nil
{
parseErr
(
err
,
resp
)
return
...
...
pkg/models/devops/devops.go
浏览文件 @
52b63f5e
...
...
@@ -340,8 +340,21 @@ func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, er
return
resBody
,
err
}
func
RunPipeline
(
projectName
,
pipelineName
,
branchName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
RunPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
)
func
RunBranchPipeline
(
projectName
,
pipelineName
,
branchName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
RunBranchPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
err
}
return
res
,
err
}
func
RunPipeline
(
projectName
,
pipelineName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
RunPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
pkg/models/devops/urlconfig.go
浏览文件 @
52b63f5e
...
...
@@ -23,7 +23,8 @@ const (
GetBranchPipeUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/"
GetPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/"
SearchPipelineUrl
=
"/blue/rest/search/?"
RunPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/"
RunBranchPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/"
RunPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/"
GetPipelineRunUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/"
GetPipeBranchRunUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/"
SearchPipelineRunUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/?"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录