Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
a545effe
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看板
未验证
提交
a545effe
编写于
3月 25, 2021
作者:
R
rick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix fields missing when convert Jenkinsfile to JSON
Signed-off-by:
N
rick
<
1450685+LinuxSuRen@users.noreply.github.com
>
上级
46e06487
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
19 addition
and
55 deletion
+19
-55
pkg/kapis/devops/v1alpha2/register.go
pkg/kapis/devops/v1alpha2/register.go
+9
-2
pkg/models/devops/devops.go
pkg/models/devops/devops.go
+2
-2
pkg/simple/client/devops/fake/fakedevops.go
pkg/simple/client/devops/fake/fakedevops.go
+1
-1
pkg/simple/client/devops/jenkins/jenkins.go
pkg/simple/client/devops/jenkins/jenkins.go
+1
-1
pkg/simple/client/devops/jenkins/pipeline.go
pkg/simple/client/devops/jenkins/pipeline.go
+5
-14
pkg/simple/client/devops/pipeline.go
pkg/simple/client/devops/pipeline.go
+1
-35
未找到文件。
pkg/kapis/devops/v1alpha2/register.go
浏览文件 @
a545effe
...
...
@@ -614,6 +614,13 @@ func AddPipelineToWebService(webservice *restful.WebService, devopsClient devops
Writes
(
devops
.
ResJenkinsfile
{}))
// match /pipeline-model-converter/toJson
/*
* Considering the following reasons, we use a generic data struct here.
* - A fixed go struct might need to change again once Jenkins has new features.
* - No refer requirement for the specific data struct
* Please read the official document if you want to know more details
* https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/fc8d22192d7d3a17badc3b8af7191a84bb7fd4ca/EXTENDING.md#conversion-to-json-representation-from-jenkinsfile
*/
webservice
.
Route
(
webservice
.
POST
(
"/tojson"
)
.
To
(
projectPipelineHandler
.
ToJson
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsJenkinsfileTag
})
.
...
...
@@ -621,8 +628,8 @@ func AddPipelineToWebService(webservice *restful.WebService, devopsClient devops
Produces
(
"application/json"
,
"charset=utf-8"
)
.
Doc
(
"Convert jenkinsfile to json format. Usually the frontend uses json to show or edit pipeline"
)
.
Reads
(
devops
.
ReqJenkinsfile
{})
.
Returns
(
http
.
StatusOK
,
RespOK
,
devops
.
ResJson
{})
.
Writes
(
devops
.
ResJson
{}))
Returns
(
http
.
StatusOK
,
RespOK
,
map
[
string
]
interface
{}
{})
.
Writes
(
map
[
string
]
interface
{}
{}))
}
return
nil
}
...
...
pkg/models/devops/devops.go
浏览文件 @
a545effe
...
...
@@ -115,7 +115,7 @@ type DevopsOperator interface {
CheckCron
(
projectName
string
,
req
*
http
.
Request
)
(
*
devops
.
CheckCronRes
,
error
)
ToJenkinsfile
(
req
*
http
.
Request
)
(
*
devops
.
ResJenkinsfile
,
error
)
ToJson
(
req
*
http
.
Request
)
(
*
devops
.
ResJson
,
error
)
ToJson
(
req
*
http
.
Request
)
(
map
[
string
]
interface
{}
,
error
)
}
type
devopsOperator
struct
{
...
...
@@ -932,7 +932,7 @@ func (d devopsOperator) ToJenkinsfile(req *http.Request) (*devops.ResJenkinsfile
return
res
,
err
}
func
(
d
devopsOperator
)
ToJson
(
req
*
http
.
Request
)
(
*
devops
.
ResJson
,
error
)
{
func
(
d
devopsOperator
)
ToJson
(
req
*
http
.
Request
)
(
map
[
string
]
interface
{}
,
error
)
{
res
,
err
:=
d
.
devopsClient
.
ToJson
(
convertToHttpParameters
(
req
))
if
err
!=
nil
{
...
...
pkg/simple/client/devops/fake/fakedevops.go
浏览文件 @
a545effe
...
...
@@ -297,7 +297,7 @@ func (d *Devops) CheckCron(projectName string, httpParameters *devops.HttpParame
func
(
d
*
Devops
)
ToJenkinsfile
(
httpParameters
*
devops
.
HttpParameters
)
(
*
devops
.
ResJenkinsfile
,
error
)
{
return
nil
,
nil
}
func
(
d
*
Devops
)
ToJson
(
httpParameters
*
devops
.
HttpParameters
)
(
*
devops
.
ResJson
,
error
)
{
func
(
d
*
Devops
)
ToJson
(
httpParameters
*
devops
.
HttpParameters
)
(
map
[
string
]
interface
{}
,
error
)
{
return
nil
,
nil
}
...
...
pkg/simple/client/devops/jenkins/jenkins.go
浏览文件 @
a545effe
...
...
@@ -872,7 +872,7 @@ func (j *Jenkins) ToJenkinsfile(httpParameters *devops.HttpParameters) (*devops.
return
res
,
err
}
func
(
j
*
Jenkins
)
ToJson
(
httpParameters
*
devops
.
HttpParameters
)
(
*
devops
.
ResJson
,
error
)
{
func
(
j
*
Jenkins
)
ToJson
(
httpParameters
*
devops
.
HttpParameters
)
(
map
[
string
]
interface
{}
,
error
)
{
PipelineOjb
:=
&
Pipeline
{
HttpParameters
:
httpParameters
,
Jenkins
:
j
,
...
...
pkg/simple/client/devops/jenkins/pipeline.go
浏览文件 @
a545effe
...
...
@@ -856,19 +856,10 @@ func (p *Pipeline) ToJenkinsfile() (*devops.ResJenkinsfile, error) {
return
&
jenkinsfile
,
err
}
func
(
p
*
Pipeline
)
ToJson
()
(
*
devops
.
ResJson
,
error
)
{
res
,
err
:=
p
.
Jenkins
.
SendPureRequest
(
p
.
Path
,
p
.
HttpParameters
)
if
err
!=
nil
{
klog
.
Error
(
err
)
return
nil
,
err
func
(
p
*
Pipeline
)
ToJson
()
(
result
map
[
string
]
interface
{},
err
error
)
{
var
data
[]
byte
if
data
,
err
=
p
.
Jenkins
.
SendPureRequest
(
p
.
Path
,
p
.
HttpParameters
);
err
==
nil
{
err
=
json
.
Unmarshal
(
data
,
&
result
)
}
var
toJson
devops
.
ResJson
err
=
json
.
Unmarshal
(
res
,
&
toJson
)
if
err
!=
nil
{
klog
.
Error
(
err
)
return
nil
,
err
}
return
&
toJson
,
err
return
}
pkg/simple/client/devops/pipeline.go
浏览文件 @
a545effe
...
...
@@ -1025,40 +1025,6 @@ type ReqJenkinsfile struct {
Jenkinsfile
string
`json:"jenkinsfile,omitempty" description:"jenkinsfile"`
}
type
ResJson
struct
{
Status
string
`json:"status,omitempty" description:"status e.g. ok"`
Data
struct
{
Result
string
`json:"result,omitempty" description:"result e.g. success"`
JSON
struct
{
Pipeline
struct
{
Stages
[]
interface
{}
`json:"stages,omitempty" description:"stages"`
Agent
struct
{
Type
string
`json:"type,omitempty" description:"type"`
Arguments
[]
struct
{
Key
string
`json:"key,omitempty" description:"key"`
Value
struct
{
IsLiteral
bool
`json:"isLiteral,omitempty" description:"is literal or not"`
Value
string
`json:"value,omitempty" description:"value"`
}
`json:"value,omitempty"`
}
`json:"arguments,omitempty"`
}
`json:"agent,omitempty"`
Parameters
struct
{
Parameters
[]
struct
{
Name
string
`json:"name,omitempty" description:"name"`
Arguments
[]
struct
{
Key
string
`json:"key,omitempty" description:"key"`
Value
struct
{
IsLiteral
bool
`json:"isLiteral,omitempty" description:"is literal or not"`
Value
interface
{}
`json:"value,omitempty" description:"value"`
}
`json:"value,omitempty"`
}
`json:"arguments,omitempty"`
}
`json:"parameters,omitempty"`
}
`json:"parameters,omitempty"`
}
`json:"pipeline,omitempty"`
}
`json:"json,omitempty"`
}
`json:"data,omitempty"`
}
type
NodesDetail
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
{
...
...
@@ -1202,5 +1168,5 @@ type PipelineOperator interface {
CheckScriptCompile
(
projectName
,
pipelineName
string
,
httpParameters
*
HttpParameters
)
(
*
CheckScript
,
error
)
CheckCron
(
projectName
string
,
httpParameters
*
HttpParameters
)
(
*
CheckCronRes
,
error
)
ToJenkinsfile
(
httpParameters
*
HttpParameters
)
(
*
ResJenkinsfile
,
error
)
ToJson
(
httpParameters
*
HttpParameters
)
(
*
ResJson
,
error
)
ToJson
(
httpParameters
*
HttpParameters
)
(
map
[
string
]
interface
{}
,
error
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录