Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
KubeSphere
kubesphere
提交
157c1c37
K
kubesphere
项目概览
KubeSphere
/
kubesphere
通知
144
Star
32
Fork
5
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
157c1c37
编写于
5月 16, 2019
作者:
S
soulseen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix jenkins header
Signed-off-by:
N
soulseen
<
sunzhu@yunify.com
>
上级
273aa010
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
31 deletion
+48
-31
pkg/apiserver/devops/devops.go
pkg/apiserver/devops/devops.go
+9
-2
pkg/models/devops/devops.go
pkg/models/devops/devops.go
+21
-13
pkg/models/devops/urlconfig.go
pkg/models/devops/urlconfig.go
+18
-16
未找到文件。
pkg/apiserver/devops/devops.go
浏览文件 @
157c1c37
...
...
@@ -104,11 +104,15 @@ func GetBranchStepLog(req *restful.Request, resp *restful.Response) {
nodeId
:=
req
.
PathParameter
(
"nodeId"
)
stepId
:=
req
.
PathParameter
(
"stepId"
)
res
,
err
:=
devops
.
GetBranchStepLog
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
,
req
.
Request
)
res
,
header
,
err
:=
devops
.
GetBranchStepLog
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
,
req
.
Request
)
if
err
!=
nil
{
parseErr
(
err
,
resp
)
return
}
for
k
,
v
:=
range
header
{
resp
.
AddHeader
(
k
,
v
[
0
])
}
resp
.
Write
(
res
)
}
...
...
@@ -119,11 +123,14 @@ func GetStepLog(req *restful.Request, resp *restful.Response) {
nodeId
:=
req
.
PathParameter
(
"nodeId"
)
stepId
:=
req
.
PathParameter
(
"stepId"
)
res
,
err
:=
devops
.
GetStepLog
(
projectName
,
pipelineName
,
runId
,
nodeId
,
stepId
,
req
.
Request
)
res
,
header
,
err
:=
devops
.
GetStepLog
(
projectName
,
pipelineName
,
runId
,
nodeId
,
stepId
,
req
.
Request
)
if
err
!=
nil
{
parseErr
(
err
,
resp
)
return
}
for
k
,
v
:=
range
header
{
resp
.
AddHeader
(
k
,
v
[
0
])
}
resp
.
Write
(
res
)
}
...
...
pkg/models/devops/devops.go
浏览文件 @
157c1c37
...
...
@@ -106,30 +106,31 @@ func GetPipelineRunNodesbyBranch(projectName, pipelineName, branchName, runId st
return
res
,
err
}
func
GetBranchStepLog
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
func
GetBranchStepLog
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
string
,
req
*
http
.
Request
)
([]
byte
,
http
.
Header
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetBranchStepLogUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
resBody
,
err
:=
sendJenkinsReques
t
(
baseUrl
,
req
)
resBody
,
header
,
err
:=
jenkinsClien
t
(
baseUrl
,
req
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
err
return
nil
,
nil
,
err
}
return
resBody
,
err
return
resBody
,
header
,
err
}
func
GetStepLog
(
projectName
,
pipelineName
,
runId
,
nodeId
,
stepId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
func
GetStepLog
(
projectName
,
pipelineName
,
runId
,
nodeId
,
stepId
string
,
req
*
http
.
Request
)
([]
byte
,
http
.
Header
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetStepLogUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
runId
,
nodeId
,
stepId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
resBody
,
err
:=
sendJenkinsReques
t
(
baseUrl
,
req
)
resBody
,
header
,
err
:=
jenkinsClien
t
(
baseUrl
,
req
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
err
return
nil
,
nil
,
err
}
return
resBody
,
err
return
resBody
,
header
,
err
}
func
Validate
(
scmId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
...
...
@@ -658,10 +659,15 @@ func GetNodesDetail(projectName, pipelineName, runId string, req *http.Request)
// create jenkins request
func
sendJenkinsRequest
(
baseUrl
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
resBody
,
_
,
err
:=
jenkinsClient
(
baseUrl
,
req
)
return
resBody
,
err
}
func
jenkinsClient
(
baseUrl
string
,
req
*
http
.
Request
)
([]
byte
,
http
.
Header
,
error
)
{
newReqUrl
,
err
:=
url
.
Parse
(
baseUrl
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
err
return
nil
,
nil
,
err
}
client
:=
&
http
.
Client
{
Timeout
:
30
*
time
.
Second
}
...
...
@@ -678,19 +684,21 @@ func sendJenkinsRequest(baseUrl string, req *http.Request) ([]byte, error) {
resp
,
err
:=
client
.
Do
(
newRequest
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
nil
,
err
return
nil
,
nil
,
err
}
defer
resp
.
Body
.
Close
()
resBody
,
_
:=
getRespBody
(
resp
)
defer
resp
.
Body
.
Close
()
if
resp
.
StatusCode
>=
http
.
StatusBadRequest
{
jkerr
:=
new
(
JkError
)
jkerr
.
Code
=
resp
.
StatusCode
jkerr
.
Message
=
http
.
StatusText
(
resp
.
StatusCode
)
return
nil
,
jkerr
return
nil
,
nil
,
jkerr
}
return
resBody
,
err
return
resBody
,
resp
.
Header
,
nil
}
// Decompress response.body of JenkinsAPIResponse
...
...
pkg/models/devops/urlconfig.go
浏览文件 @
157c1c37
...
...
@@ -19,29 +19,31 @@ package devops
// Some apis for Jenkins.
const
(
GetPipeBranchUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/?"
GetPipeBranchUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/branches/?"
GetBranchPipeUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/"
GetPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/"
GetPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/"
SearchPipelineUrl
=
"/blue/rest/search/?"
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/?"
GetBranchPipeRunNodesUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/nodes/?"
GetPipeRunNodesUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/nodes/?"
GetBranchRunLogUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/log/?"
GetRunLogUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/log/?"
GetBranchStepLogUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/nodes/%s/steps/%s/log/?"
GetStepLogUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/nodes/%s/steps/%s/log/?"
RunBranchPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/branches/%s/runs/"
RunPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/runs/"
GetPipelineRunUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/runs/%s/"
GetPipeBranchRunUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/branches/%s/runs/%s/"
SearchPipelineRunUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/runs/?"
GetBranchPipeRunNodesUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/branches/%s/runs/%s/nodes/?"
GetPipeRunNodesUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/runs/%s/nodes/?"
GetBranchRunLogUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/branches/%s/runs/%s/log/?"
GetRunLogUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/runs/%s/log/?"
GetBranchStepLogUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/branches/%s/runs/%s/nodes/%s/steps/%s/log/?"
GetStepLogUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/
pipelines/
%s/runs/%s/nodes/%s/steps/%s/log/?"
StopBranchPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/stop/?"
StopPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/stop/?"
ReplayBranchPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/replay/"
ReplayPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/replay/"
GetBranchArtifactsUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/artifacts/?"
GetArtifactsUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/artifacts/?"
GetBranchStepsStatusUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/nodes/%s/steps/?"
GetBranchArtifactsUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/artifacts/?"
GetArtifactsUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/artifacts/?"
GetBranchStepsStatusUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/?"
GetStepsStatusUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/nodes/%s/steps/?"
CheckBranchPipelineUrl
=
"/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%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/%s/branches/%s/runs/%s/nodes/%s/steps/?"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录