Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
9f24801e
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,发现更多精彩内容 >>
提交
9f24801e
编写于
5月 06, 2019
作者:
S
soulseen
提交者:
zryfish
5月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update jenkins pre-check
Signed-off-by:
N
soulseen
<
sunzhu@yunify.com
>
上级
a57947fd
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
39 addition
and
69 deletion
+39
-69
cmd/ks-apiserver/app/server.go
cmd/ks-apiserver/app/server.go
+0
-2
pkg/models/devops/devops.go
pkg/models/devops/devops.go
+35
-60
pkg/simple/client/admin_jenkins/jenkins.go
pkg/simple/client/admin_jenkins/jenkins.go
+0
-4
vendor/github.com/emicklei/go-restful/constants.go
vendor/github.com/emicklei/go-restful/constants.go
+4
-3
未找到文件。
cmd/ks-apiserver/app/server.go
浏览文件 @
9f24801e
...
...
@@ -33,7 +33,6 @@ import (
"kubesphere.io/kubesphere/pkg/models/devops"
logging
"kubesphere.io/kubesphere/pkg/models/log"
"kubesphere.io/kubesphere/pkg/signals"
"kubesphere.io/kubesphere/pkg/simple/client/admin_jenkins"
"kubesphere.io/kubesphere/pkg/simple/client/devops_mysql"
"log"
"net/http"
...
...
@@ -100,7 +99,6 @@ func Run(s *options.ServerRunOptions) error {
func
initializeAdminJenkins
()
{
devops
.
PreCheckJenkins
()
admin_jenkins
.
Client
()
}
func
initializeDevOpsDatabase
()
{
...
...
pkg/models/devops/devops.go
浏览文件 @
9f24801e
...
...
@@ -21,49 +21,24 @@ import (
"compress/gzip"
"fmt"
"github.com/PuerkitoBio/goquery"
"github.com/emicklei/go-restful"
log
"github.com/golang/glog"
"io"
"io/ioutil"
"kubesphere.io/kubesphere/pkg/gojenkins"
"kubesphere.io/kubesphere/pkg/simple/client/admin_jenkins"
"net/http"
"net/url"
"strings"
"time"
)
const
MIME_FORM
=
"application/x-www-form-urlencoded"
var
(
jenkinsUrl
string
jenkinsAdminUsername
string
jenkinsAdminPassword
string
)
var
jenkins
*
gojenkins
.
Jenkins
func
PreCheckJenkins
()
{
jenkinsUrl
,
jenkinsAdminUsername
,
jenkinsAdminPassword
=
admin_jenkins
.
GetJenkinsFlag
()
baseUrl
:=
jenkinsUrl
+
LoginUrl
client
:=
&
http
.
Client
{
Timeout
:
30
*
time
.
Second
}
loginReq
,
_
:=
http
.
NewRequest
(
http
.
MethodPost
,
baseUrl
,
strings
.
NewReader
(
""
))
loginReq
.
Header
.
Add
(
restful
.
HEADER_ContentType
,
MIME_FORM
)
loginReq
.
SetBasicAuth
(
jenkinsAdminUsername
,
jenkinsAdminPassword
)
resp
,
err
:=
client
.
Do
(
loginReq
)
if
err
!=
nil
{
log
.
Error
(
"Check Jenkins Error: "
,
err
)
}
if
resp
.
StatusCode
!=
http
.
StatusOK
{
log
.
Error
(
"Check Jenkins Error: "
,
resp
.
StatusCode
,
http
.
StatusText
(
resp
.
StatusCode
))
}
else
{
log
.
Infof
(
"Client Jenkins Success: "
+
baseUrl
)
}
jenkins
=
admin_jenkins
.
Client
()
}
func
GetPipeline
(
projectName
,
pipelineName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetPipelineUrl
,
projectName
,
pipelineName
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetPipelineUrl
,
projectName
,
pipelineName
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -76,7 +51,7 @@ func GetPipeline(projectName, pipelineName string, req *http.Request) ([]byte, e
}
func
SearchPipelines
(
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
jenkins
Url
+
SearchPipelineUrl
+
req
.
URL
.
RawQuery
baseUrl
:=
jenkins
.
Server
+
SearchPipelineUrl
+
req
.
URL
.
RawQuery
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -89,7 +64,7 @@ func SearchPipelines(req *http.Request) ([]byte, error) {
}
func
SearchPipelineRuns
(
projectName
,
pipelineName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
SearchPipelineRunUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
SearchPipelineRunUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -102,7 +77,7 @@ func SearchPipelineRuns(projectName, pipelineName string, req *http.Request) ([]
}
func
GetBranchPipelineRun
(
projectName
,
pipelineName
,
branchName
,
runId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetPipeBranchRunUrl
,
projectName
,
pipelineName
,
branchName
,
runId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetPipeBranchRunUrl
,
projectName
,
pipelineName
,
branchName
,
runId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -115,7 +90,7 @@ func GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, r
}
func
GetPipelineRunNodesbyBranch
(
projectName
,
pipelineName
,
branchName
,
runId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetBranchPipeRunNodesUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetBranchPipeRunNodesUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -128,7 +103,7 @@ func GetPipelineRunNodesbyBranch(projectName, pipelineName, branchName, runId st
}
func
GetStepLog
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetStepLogUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetStepLogUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -141,7 +116,7 @@ func GetStepLog(projectName, pipelineName, branchName, runId, nodeId, stepId str
}
func
Validate
(
scmId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
ValidateUrl
,
scmId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
ValidateUrl
,
scmId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -154,7 +129,7 @@ func Validate(scmId string, req *http.Request) ([]byte, error) {
}
func
GetSCMOrg
(
scmId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetSCMOrgUrl
+
req
.
URL
.
RawQuery
,
scmId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetSCMOrgUrl
+
req
.
URL
.
RawQuery
,
scmId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -167,7 +142,7 @@ func GetSCMOrg(scmId string, req *http.Request) ([]byte, error) {
}
func
GetOrgRepo
(
scmId
,
organizationId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetOrgRepoUrl
+
req
.
URL
.
RawQuery
,
scmId
,
organizationId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetOrgRepoUrl
+
req
.
URL
.
RawQuery
,
scmId
,
organizationId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -180,7 +155,7 @@ func GetOrgRepo(scmId, organizationId string, req *http.Request) ([]byte, error)
}
func
StopPipeline
(
projectName
,
pipelineName
,
branchName
,
runId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
StopPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
StopPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -193,7 +168,7 @@ func StopPipeline(projectName, pipelineName, branchName, runId string, req *http
}
func
ReplayPipeline
(
projectName
,
pipelineName
,
branchName
,
runId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
ReplayPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
ReplayPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -206,7 +181,7 @@ func ReplayPipeline(projectName, pipelineName, branchName, runId string, req *ht
}
func
GetRunLog
(
projectName
,
pipelineName
,
branchName
,
runId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetRunLogUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetRunLogUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -219,7 +194,7 @@ func GetRunLog(projectName, pipelineName, branchName, runId string, req *http.Re
}
func
GetArtifacts
(
projectName
,
pipelineName
,
branchName
,
runId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetArtifactsUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetArtifactsUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -232,7 +207,7 @@ func GetArtifacts(projectName, pipelineName, branchName, runId string, req *http
}
func
GetPipeBranch
(
projectName
,
pipelineName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetPipeBranchUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetPipeBranchUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -245,7 +220,7 @@ func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte,
}
func
CheckPipeline
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
CheckPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
CheckPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
,
stepId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -258,7 +233,7 @@ func CheckPipeline(projectName, pipelineName, branchName, runId, nodeId, stepId
}
func
GetConsoleLog
(
projectName
,
pipelineName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetConsoleLogUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetConsoleLogUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -271,7 +246,7 @@ func GetConsoleLog(projectName, pipelineName string, req *http.Request) ([]byte,
}
func
ScanBranch
(
projectName
,
pipelineName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
ScanBranchUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
ScanBranchUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -284,7 +259,7 @@ func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, er
}
func
RunPipeline
(
projectName
,
pipelineName
,
branchName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
RunPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
RunPipelineUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -297,7 +272,7 @@ func RunPipeline(projectName, pipelineName, branchName string, req *http.Request
}
func
GetStepsStatus
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetStepsStatusUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetStepsStatusUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -310,7 +285,7 @@ func GetStepsStatus(projectName, pipelineName, branchName, runId, nodeId string,
}
func
GetCrumb
(
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetCrumbUrl
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetCrumbUrl
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -323,9 +298,9 @@ func GetCrumb(req *http.Request) ([]byte, error) {
}
func
CheckScriptCompile
(
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
jenkins
Url
+
CheckScriptCompileUrl
baseUrl
:=
jenkins
.
Server
+
CheckScriptCompileUrl
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
req
.
SetBasicAuth
(
jenkins
AdminUsername
,
jenkinsAdmin
Password
)
req
.
SetBasicAuth
(
jenkins
.
Requester
.
BasicAuth
.
Username
,
jenkins
.
Requester
.
BasicAuth
.
Password
)
resBody
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
if
err
!=
nil
{
...
...
@@ -337,9 +312,9 @@ func CheckScriptCompile(req *http.Request) ([]byte, error) {
}
func
CheckCron
(
req
*
http
.
Request
)
(
*
CheckCronRes
,
error
)
{
baseUrl
:=
jenkins
Url
+
CheckCronUrl
+
req
.
URL
.
RawQuery
baseUrl
:=
jenkins
.
Server
+
CheckCronUrl
+
req
.
URL
.
RawQuery
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
req
.
SetBasicAuth
(
jenkins
AdminUsername
,
jenkinsAdmin
Password
)
req
.
SetBasicAuth
(
jenkins
.
Requester
.
BasicAuth
.
Username
,
jenkins
.
Requester
.
BasicAuth
.
Password
)
var
res
=
new
(
CheckCronRes
)
resp
,
err
:=
http
.
Get
(
baseUrl
)
...
...
@@ -362,7 +337,7 @@ func CheckCron(req *http.Request) (*CheckCronRes, error) {
}
func
GetPipelineRun
(
projectName
,
pipelineName
,
runId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetPipelineRunUrl
,
projectName
,
pipelineName
,
runId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetPipelineRunUrl
,
projectName
,
pipelineName
,
runId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -375,7 +350,7 @@ func GetPipelineRun(projectName, pipelineName, runId string, req *http.Request)
}
func
GetBranchPipeline
(
projectName
,
pipelineName
,
branchName
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetBranchPipeUrl
,
projectName
,
pipelineName
,
branchName
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetBranchPipeUrl
,
projectName
,
pipelineName
,
branchName
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -388,7 +363,7 @@ func GetBranchPipeline(projectName, pipelineName, branchName string, req *http.R
}
func
GetPipelineRunNodes
(
projectName
,
pipelineName
,
runId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetPipeRunNodesUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
runId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetPipeRunNodesUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
runId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -401,7 +376,7 @@ func GetPipelineRunNodes(projectName, pipelineName, runId string, req *http.Requ
}
func
GetNodeSteps
(
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
string
,
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetNodeStepsUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetNodeStepsUrl
+
req
.
URL
.
RawQuery
,
projectName
,
pipelineName
,
branchName
,
runId
,
nodeId
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -414,7 +389,7 @@ func GetNodeSteps(projectName, pipelineName, branchName, runId, nodeId string, r
}
func
ToJenkinsfile
(
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
ToJenkinsfileUrl
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
ToJenkinsfileUrl
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -427,7 +402,7 @@ func ToJenkinsfile(req *http.Request) ([]byte, error) {
}
func
ToJson
(
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
ToJsonUrl
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
ToJsonUrl
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
@@ -440,7 +415,7 @@ func ToJson(req *http.Request) ([]byte, error) {
}
func
GetNotifyCommit
(
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GetNotifyCommitUrl
+
req
.
URL
.
RawQuery
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GetNotifyCommitUrl
+
req
.
URL
.
RawQuery
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
req
.
Method
=
"GET"
...
...
@@ -454,7 +429,7 @@ func GetNotifyCommit(req *http.Request) ([]byte, error) {
}
func
GithubWebhook
(
req
*
http
.
Request
)
([]
byte
,
error
)
{
baseUrl
:=
fmt
.
Sprintf
(
jenkins
Url
+
GithubWebhookUrl
+
req
.
URL
.
RawQuery
)
baseUrl
:=
fmt
.
Sprintf
(
jenkins
.
Server
+
GithubWebhookUrl
+
req
.
URL
.
RawQuery
)
log
.
Infof
(
"Jenkins-url: "
+
baseUrl
)
res
,
err
:=
sendJenkinsRequest
(
baseUrl
,
req
)
...
...
pkg/simple/client/admin_jenkins/jenkins.go
浏览文件 @
9f24801e
...
...
@@ -40,10 +40,6 @@ func init() {
flag
.
IntVar
(
&
jenkinsMaxConn
,
"jenkins-max-conn"
,
20
,
"max conn to jenkins"
)
}
func
GetJenkinsFlag
()
(
string
,
string
,
string
){
return
jenkinsAdminAddress
,
jenkinsAdminUsername
,
jenkinsAdminPassword
}
func
Client
()
*
gojenkins
.
Jenkins
{
jenkinsClientOnce
.
Do
(
func
()
{
jenkins
:=
gojenkins
.
CreateJenkins
(
nil
,
jenkinsAdminAddress
,
jenkinsMaxConn
,
jenkinsAdminUsername
,
jenkinsAdminPassword
)
...
...
vendor/github.com/emicklei/go-restful/constants.go
浏览文件 @
9f24801e
...
...
@@ -7,6 +7,7 @@ package restful
const
(
MIME_XML
=
"application/xml"
// Accept or Content-Type used in Consumes() and/or Produces()
MIME_JSON
=
"application/json"
// Accept or Content-Type used in Consumes() and/or Produces()
MIME_FORM
=
"application/x-www-form-urlencoded"
// Accept or Content-Type used in Consumes() and/or Produces()
MIME_OCTET
=
"application/octet-stream"
// If Content-Type is not present in request, use the default
HEADER_Allow
=
"Allow"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录