Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
dde017c4
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,发现更多精彩内容 >>
未验证
提交
dde017c4
编写于
7月 04, 2019
作者:
S
soulseen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix checkpipeline
Signed-off-by:
N
soulseen
<
sunzhu@yunify.com
>
上级
d30dba89
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
68 addition
and
14 deletion
+68
-14
pkg/apis/devops/v1alpha2/register.go
pkg/apis/devops/v1alpha2/register.go
+2
-2
pkg/apiserver/devops/devops.go
pkg/apiserver/devops/devops.go
+4
-4
pkg/models/devops/devops.go
pkg/models/devops/devops.go
+54
-2
pkg/models/devops/json.go
pkg/models/devops/json.go
+8
-6
未找到文件。
pkg/apis/devops/v1alpha2/register.go
浏览文件 @
dde017c4
...
@@ -516,7 +516,7 @@ The last one is encrypted info, such as the password of the username-password ty
...
@@ -516,7 +516,7 @@ The last one is encrypted info, such as the password of the username-password ty
// /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step}
// /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step}
webservice
.
Route
(
webservice
.
POST
(
"/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step}"
)
.
webservice
.
Route
(
webservice
.
POST
(
"/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step}"
)
.
To
(
devopsapi
.
CheckBranchPipeline
)
.
To
(
devopsapi
.
SubmitBranchInputStep
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsPipelineTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsPipelineTag
})
.
Doc
(
"(MultiBranchesPipeline) Proceed or Break the paused pipeline which waiting for user input."
)
.
Doc
(
"(MultiBranchesPipeline) Proceed or Break the paused pipeline which waiting for user input."
)
.
Param
(
webservice
.
PathParameter
(
"devops"
,
"DevOps project's ID, e.g. project-RRRRAzLBlLEm"
))
.
Param
(
webservice
.
PathParameter
(
"devops"
,
"DevOps project's ID, e.g. project-RRRRAzLBlLEm"
))
.
...
@@ -530,7 +530,7 @@ The last one is encrypted info, such as the password of the username-password ty
...
@@ -530,7 +530,7 @@ The last one is encrypted info, such as the password of the username-password ty
// match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step}
// match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step}
webservice
.
Route
(
webservice
.
POST
(
"/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step}"
)
.
webservice
.
Route
(
webservice
.
POST
(
"/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step}"
)
.
To
(
devopsapi
.
CheckPipeline
)
.
To
(
devopsapi
.
SubmitInputStep
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsPipelineTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsPipelineTag
})
.
Doc
(
"Proceed or Break the paused pipeline which waiting for user input."
)
.
Doc
(
"Proceed or Break the paused pipeline which waiting for user input."
)
.
Reads
(
devops
.
CheckPlayload
{})
.
Reads
(
devops
.
CheckPlayload
{})
.
...
...
pkg/apiserver/devops/devops.go
浏览文件 @
dde017c4
...
@@ -314,7 +314,7 @@ func GetPipeBranch(req *restful.Request, resp *restful.Response) {
...
@@ -314,7 +314,7 @@ func GetPipeBranch(req *restful.Request, resp *restful.Response) {
resp
.
Write
(
res
)
resp
.
Write
(
res
)
}
}
func
CheckBranchPipeline
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
SubmitBranchInputStep
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
projectName
:=
req
.
PathParameter
(
"devops"
)
projectName
:=
req
.
PathParameter
(
"devops"
)
pipelineName
:=
req
.
PathParameter
(
"pipeline"
)
pipelineName
:=
req
.
PathParameter
(
"pipeline"
)
branchName
:=
req
.
PathParameter
(
"branch"
)
branchName
:=
req
.
PathParameter
(
"branch"
)
...
@@ -322,7 +322,7 @@ func CheckBranchPipeline(req *restful.Request, resp *restful.Response) {
...
@@ -322,7 +322,7 @@ func CheckBranchPipeline(req *restful.Request, resp *restful.Response) {
nodeId
:=
req
.
PathParameter
(
"node"
)
nodeId
:=
req
.
PathParameter
(
"node"
)
stepId
:=
req
.
PathParameter
(
"step"
)
stepId
:=
req
.
PathParameter
(
"step"
)
res
,
err
:=
devops
.
CheckBranchPipeline
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
,
req
.
Request
)
res
,
err
:=
devops
.
SubmitBranchInputStep
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
,
req
.
Request
)
if
err
!=
nil
{
if
err
!=
nil
{
parseErr
(
err
,
resp
)
parseErr
(
err
,
resp
)
return
return
...
@@ -331,14 +331,14 @@ func CheckBranchPipeline(req *restful.Request, resp *restful.Response) {
...
@@ -331,14 +331,14 @@ func CheckBranchPipeline(req *restful.Request, resp *restful.Response) {
resp
.
Write
(
res
)
resp
.
Write
(
res
)
}
}
func
CheckPipeline
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
SubmitInputStep
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
projectName
:=
req
.
PathParameter
(
"devops"
)
projectName
:=
req
.
PathParameter
(
"devops"
)
pipelineName
:=
req
.
PathParameter
(
"pipeline"
)
pipelineName
:=
req
.
PathParameter
(
"pipeline"
)
runId
:=
req
.
PathParameter
(
"run"
)
runId
:=
req
.
PathParameter
(
"run"
)
nodeId
:=
req
.
PathParameter
(
"node"
)
nodeId
:=
req
.
PathParameter
(
"node"
)
stepId
:=
req
.
PathParameter
(
"step"
)
stepId
:=
req
.
PathParameter
(
"step"
)
res
,
err
:=
devops
.
CheckPipeline
(
projectName
,
pipelineName
,
runId
,
nodeId
,
stepId
,
req
.
Request
)
res
,
err
:=
devops
.
SubmitInputStep
(
projectName
,
pipelineName
,
runId
,
nodeId
,
stepId
,
req
.
Request
)
if
err
!=
nil
{
if
err
!=
nil
{
parseErr
(
err
,
resp
)
parseErr
(
err
,
resp
)
return
return
...
...
pkg/models/devops/devops.go
浏览文件 @
dde017c4
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
package
devops
package
devops
import
(
import
(
"bytes"
"compress/gzip"
"compress/gzip"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
...
@@ -293,10 +294,16 @@ func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte,
...
@@ -293,10 +294,16 @@ func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte,
return
res
,
err
return
res
,
err
}
}
func
CheckBranchPipeline
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
func
SubmitBranchInputStep
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
CheckBranchPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
CheckBranchPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
)
log
.
Info
(
"Jenkins-url: "
+
baseUrl
)
log
.
Info
(
"Jenkins-url: "
+
baseUrl
)
newBody
,
err
:=
getInputReqBody
(
req
.
Body
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
err
}
req
.
Body
=
newBody
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
err
)
log
.
Error
(
err
)
...
@@ -306,10 +313,16 @@ func CheckBranchPipeline(projectName, pipelineName, branchName, runId, nodeId, s
...
@@ -306,10 +313,16 @@ func CheckBranchPipeline(projectName, pipelineName, branchName, runId, nodeId, s
return
resBody
,
err
return
resBody
,
err
}
}
func
CheckPipeline
(
projectName
,
pipelineName
,
runId
,
nodeId
,
stepId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
func
SubmitInputStep
(
projectName
,
pipelineName
,
runId
,
nodeId
,
stepId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
CheckPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
runId
,
nodeId
,
stepId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
CheckPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
runId
,
nodeId
,
stepId
)
log
.
Info
(
"Jenkins-url: "
+
baseUrl
)
log
.
Info
(
"Jenkins-url: "
+
baseUrl
)
newBody
,
err
:=
getInputReqBody
(
req
.
Body
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
err
}
req
.
Body
=
newBody
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
err
)
log
.
Error
(
err
)
...
@@ -319,6 +332,45 @@ func CheckPipeline(projectName, pipelineName, runId, nodeId, stepId string, req
...
@@ -319,6 +332,45 @@ func CheckPipeline(projectName, pipelineName, runId, nodeId, stepId string, req
return
resBody
,
err
return
resBody
,
err
}
}
func
getInputReqBody
(
reqBody
io
.
ReadCloser
)
(
newReqBody
io
.
ReadCloser
,
err
error
)
{
var
checkBody
CheckPlayload
var
jsonBody
[]
byte
var
workRound
struct
{
ID
string
`json:"id,omitempty" description:"id"`
Parameters
[]
CheckPlayloadParameters
`json:"parameters"`
Abort
bool
`json:"abort,omitempty" description:"abort or not"`
}
Body
,
err
:=
ioutil
.
ReadAll
(
reqBody
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
err
}
err
=
json
.
Unmarshal
(
Body
,
&
checkBody
)
if
checkBody
.
Abort
!=
true
&&
checkBody
.
Parameters
==
nil
{
workRound
.
Parameters
=
[]
CheckPlayloadParameters
{}
workRound
.
ID
=
checkBody
.
ID
jsonBody
,
_
=
json
.
Marshal
(
workRound
)
}
else
{
jsonBody
,
_
=
json
.
Marshal
(
checkBody
)
}
newReqBody
=
parseBody
(
bytes
.
NewBuffer
(
jsonBody
))
return
newReqBody
,
nil
}
func
parseBody
(
body
io
.
Reader
)
(
newReqBody
io
.
ReadCloser
)
{
rc
,
ok
:=
body
.
(
io
.
ReadCloser
)
if
!
ok
&&
body
!=
nil
{
rc
=
ioutil
.
NopCloser
(
body
)
}
return
rc
}
func
GetConsoleLog
(
projectName
,
pipelineName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
func
GetConsoleLog
(
projectName
,
pipelineName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetConsoleLogUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetConsoleLogUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
)
log
.
Info
(
"Jenkins-url: "
+
baseUrl
)
log
.
Info
(
"Jenkins-url: "
+
baseUrl
)
...
...
pkg/models/devops/json.go
浏览文件 @
dde017c4
...
@@ -716,12 +716,14 @@ type NodeStatus struct {
...
@@ -716,12 +716,14 @@ type NodeStatus struct {
// CheckPipeline
// CheckPipeline
type
CheckPlayload
struct
{
type
CheckPlayload
struct
{
ID
string
`json:"id,omitempty" description:"id"`
ID
string
`json:"id,omitempty" description:"id"`
Parameters
[]
struct
{
Parameters
[]
CheckPlayloadParameters
`json:"parameters,omitempty"`
Name
string
`json:"name,omitempty" description:"name"`
Abort
bool
`json:"abort,omitempty" description:"abort or not"`
Value
string
`json:"value,omitempty" description:"value"`
}
}
`json:"parameters,omitempty"`
Abort
bool
`json:"abort,omitempty" description:"abort or not"`
type
CheckPlayloadParameters
struct
{
Name
string
`json:"name,omitempty" description:"name"`
Value
string
`json:"value,omitempty" description:"value"`
}
}
// Getcrumb
// Getcrumb
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录