@@ -23,8 +23,11 @@ import (
|
|||||||
log "github.com/golang/glog"
|
log "github.com/golang/glog"
|
||||||
"kubesphere.io/kubesphere/pkg/models/devops"
|
"kubesphere.io/kubesphere/pkg/models/devops"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const jenkinsHeaderPre = "X-"
|
||||||
|
|
||||||
func GetPipeline(req *restful.Request, resp *restful.Response) {
|
func GetPipeline(req *restful.Request, resp *restful.Response) {
|
||||||
projectName := req.PathParameter("projectName")
|
projectName := req.PathParameter("projectName")
|
||||||
pipelineName := req.PathParameter("pipelineName")
|
pipelineName := req.PathParameter("pipelineName")
|
||||||
@@ -111,7 +114,9 @@ func GetBranchStepLog(req *restful.Request, resp *restful.Response) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for k, v := range header {
|
for k, v := range header {
|
||||||
resp.AddHeader(k, v[0])
|
if strings.HasPrefix(k, jenkinsHeaderPre) {
|
||||||
|
resp.AddHeader(k, v[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resp.Write(res)
|
resp.Write(res)
|
||||||
}
|
}
|
||||||
@@ -129,7 +134,9 @@ func GetStepLog(req *restful.Request, resp *restful.Response) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for k, v := range header {
|
for k, v := range header {
|
||||||
resp.AddHeader(k, v[0])
|
if strings.HasPrefix(k, jenkinsHeaderPre) {
|
||||||
|
resp.AddHeader(k, v[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resp.Write(res)
|
resp.Write(res)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,10 +68,11 @@ func SearchPipelines(req *http.Request) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SearchPipelineRuns(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
func SearchPipelineRuns(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+SearchPipelineRunUrl+req.URL.RawQuery, projectName, pipelineName)
|
baseUrl := fmt.Sprintf(jenkins.Server+SearchPipelineRunUrl, projectName, pipelineName)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
|
res, err := sendJenkinsRequest(baseUrl+req.URL.RawQuery, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -82,7 +83,7 @@ func SearchPipelineRuns(projectName, pipelineName string, req *http.Request) ([]
|
|||||||
|
|
||||||
func GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
func GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchRunUrl, projectName, pipelineName, branchName, runId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchRunUrl, projectName, pipelineName, branchName, runId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -95,7 +96,7 @@ func GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, r
|
|||||||
|
|
||||||
func GetPipelineRunNodesbyBranch(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
func GetPipelineRunNodesbyBranch(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+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)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -108,7 +109,7 @@ func GetPipelineRunNodesbyBranch(projectName, pipelineName, branchName, runId st
|
|||||||
|
|
||||||
func GetBranchStepLog(projectName, pipelineName, branchName, runId, nodeId, stepId string, req *http.Request) ([]byte, http.Header, 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)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchStepLogUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId, stepId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
resBody, header, err := jenkinsClient(baseUrl, req)
|
resBody, header, err := jenkinsClient(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -121,7 +122,7 @@ func GetBranchStepLog(projectName, pipelineName, branchName, runId, nodeId, step
|
|||||||
|
|
||||||
func GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, req *http.Request) ([]byte, http.Header, 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)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetStepLogUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId, stepId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
resBody, header, err := jenkinsClient(baseUrl, req)
|
resBody, header, err := jenkinsClient(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -135,7 +136,7 @@ func GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, req *ht
|
|||||||
|
|
||||||
func Validate(scmId string, req *http.Request) ([]byte, error) {
|
func Validate(scmId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+ValidateUrl, scmId)
|
baseUrl := fmt.Sprintf(jenkins.Server+ValidateUrl, scmId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -148,7 +149,7 @@ func Validate(scmId string, req *http.Request) ([]byte, error) {
|
|||||||
|
|
||||||
func GetSCMOrg(scmId string, req *http.Request) ([]byte, error) {
|
func GetSCMOrg(scmId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetSCMOrgUrl+req.URL.RawQuery, scmId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetSCMOrgUrl+req.URL.RawQuery, scmId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -161,7 +162,7 @@ func GetSCMOrg(scmId string, req *http.Request) ([]byte, error) {
|
|||||||
|
|
||||||
func GetOrgRepo(scmId, organizationId string, req *http.Request) ([]byte, error) {
|
func GetOrgRepo(scmId, organizationId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetOrgRepoUrl+req.URL.RawQuery, scmId, organizationId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetOrgRepoUrl+req.URL.RawQuery, scmId, organizationId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -174,7 +175,7 @@ func GetOrgRepo(scmId, organizationId string, req *http.Request) ([]byte, error)
|
|||||||
|
|
||||||
func StopBranchPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
func StopBranchPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+StopBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
baseUrl := fmt.Sprintf(jenkins.Server+StopBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -187,7 +188,7 @@ func StopBranchPipeline(projectName, pipelineName, branchName, runId string, req
|
|||||||
|
|
||||||
func StopPipeline(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
func StopPipeline(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+StopPipelineUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
baseUrl := fmt.Sprintf(jenkins.Server+StopPipelineUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -200,7 +201,7 @@ func StopPipeline(projectName, pipelineName, runId string, req *http.Request) ([
|
|||||||
|
|
||||||
func ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
func ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+ReplayBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
baseUrl := fmt.Sprintf(jenkins.Server+ReplayBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -213,7 +214,7 @@ func ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, r
|
|||||||
|
|
||||||
func ReplayPipeline(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
func ReplayPipeline(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+ReplayPipelineUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
baseUrl := fmt.Sprintf(jenkins.Server+ReplayPipelineUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -226,7 +227,7 @@ func ReplayPipeline(projectName, pipelineName, runId string, req *http.Request)
|
|||||||
|
|
||||||
func GetBranchRunLog(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
func GetBranchRunLog(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchRunLogUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchRunLogUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -239,7 +240,7 @@ func GetBranchRunLog(projectName, pipelineName, branchName, runId string, req *h
|
|||||||
|
|
||||||
func GetRunLog(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
func GetRunLog(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetRunLogUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetRunLogUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -252,7 +253,7 @@ func GetRunLog(projectName, pipelineName, runId string, req *http.Request) ([]by
|
|||||||
|
|
||||||
func GetBranchArtifacts(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
func GetBranchArtifacts(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchArtifactsUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchArtifactsUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -265,7 +266,7 @@ func GetBranchArtifacts(projectName, pipelineName, branchName, runId string, req
|
|||||||
|
|
||||||
func GetArtifacts(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
func GetArtifacts(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetArtifactsUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetArtifactsUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -277,10 +278,10 @@ func GetArtifacts(projectName, pipelineName, runId string, req *http.Request) ([
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchUrl+req.URL.RawQuery, projectName, pipelineName)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchUrl, projectName, pipelineName)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl+req.URL.RawQuery, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -291,7 +292,7 @@ func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte,
|
|||||||
|
|
||||||
func CheckBranchPipeline(projectName, pipelineName, branchName, runId, nodeId, stepId string, req *http.Request) ([]byte, error) {
|
func CheckBranchPipeline(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.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -304,7 +305,7 @@ func CheckBranchPipeline(projectName, pipelineName, branchName, runId, nodeId, s
|
|||||||
|
|
||||||
func CheckPipeline(projectName, pipelineName, runId, nodeId, stepId string, req *http.Request) ([]byte, error) {
|
func CheckPipeline(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.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -317,7 +318,7 @@ func CheckPipeline(projectName, pipelineName, runId, nodeId, stepId string, req
|
|||||||
|
|
||||||
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.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -330,7 +331,7 @@ func GetConsoleLog(projectName, pipelineName string, req *http.Request) ([]byte,
|
|||||||
|
|
||||||
func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+ScanBranchUrl+req.URL.RawQuery, projectName, pipelineName)
|
baseUrl := fmt.Sprintf(jenkins.Server+ScanBranchUrl+req.URL.RawQuery, projectName, pipelineName)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -343,7 +344,7 @@ func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, er
|
|||||||
|
|
||||||
func RunBranchPipeline(projectName, pipelineName, branchName string, req *http.Request) ([]byte, error) {
|
func RunBranchPipeline(projectName, pipelineName, branchName string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+RunBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName)
|
baseUrl := fmt.Sprintf(jenkins.Server+RunBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -356,7 +357,7 @@ func RunBranchPipeline(projectName, pipelineName, branchName string, req *http.R
|
|||||||
|
|
||||||
func RunPipeline(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
func RunPipeline(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+RunPipelineUrl+req.URL.RawQuery, projectName, pipelineName)
|
baseUrl := fmt.Sprintf(jenkins.Server+RunPipelineUrl+req.URL.RawQuery, projectName, pipelineName)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -369,7 +370,7 @@ func RunPipeline(projectName, pipelineName string, req *http.Request) ([]byte, e
|
|||||||
|
|
||||||
func GetBranchStepsStatus(projectName, pipelineName, branchName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
func GetBranchStepsStatus(projectName, pipelineName, branchName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchStepsStatusUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchStepsStatusUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -382,7 +383,7 @@ func GetBranchStepsStatus(projectName, pipelineName, branchName, runId, nodeId s
|
|||||||
|
|
||||||
func GetStepsStatus(projectName, pipelineName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
func GetStepsStatus(projectName, pipelineName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetStepsStatusUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetStepsStatusUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -395,7 +396,7 @@ func GetStepsStatus(projectName, pipelineName, runId, nodeId string, req *http.R
|
|||||||
|
|
||||||
func GetCrumb(req *http.Request) ([]byte, error) {
|
func GetCrumb(req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server + GetCrumbUrl)
|
baseUrl := fmt.Sprintf(jenkins.Server + GetCrumbUrl)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -408,7 +409,7 @@ func GetCrumb(req *http.Request) ([]byte, error) {
|
|||||||
|
|
||||||
func CheckScriptCompile(req *http.Request) ([]byte, error) {
|
func CheckScriptCompile(req *http.Request) ([]byte, error) {
|
||||||
baseUrl := jenkins.Server + CheckScriptCompileUrl
|
baseUrl := jenkins.Server + CheckScriptCompileUrl
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
req.SetBasicAuth(jenkins.Requester.BasicAuth.Username, jenkins.Requester.BasicAuth.Password)
|
req.SetBasicAuth(jenkins.Requester.BasicAuth.Username, jenkins.Requester.BasicAuth.Password)
|
||||||
|
|
||||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||||
@@ -454,7 +455,7 @@ func CheckCron(req *http.Request) (*CheckCronRes, error) {
|
|||||||
|
|
||||||
func GetPipelineRun(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
func GetPipelineRun(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipelineRunUrl, projectName, pipelineName, runId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetPipelineRunUrl, projectName, pipelineName, runId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -467,7 +468,7 @@ func GetPipelineRun(projectName, pipelineName, runId string, req *http.Request)
|
|||||||
|
|
||||||
func GetBranchPipeline(projectName, pipelineName, branchName string, req *http.Request) ([]byte, error) {
|
func GetBranchPipeline(projectName, pipelineName, branchName string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchPipeUrl, projectName, pipelineName, branchName)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchPipeUrl, projectName, pipelineName, branchName)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -480,7 +481,7 @@ func GetBranchPipeline(projectName, pipelineName, branchName string, req *http.R
|
|||||||
|
|
||||||
func GetPipelineRunNodes(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
func GetPipelineRunNodes(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -493,7 +494,7 @@ func GetPipelineRunNodes(projectName, pipelineName, runId string, req *http.Requ
|
|||||||
|
|
||||||
func GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
func GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchNodeStepsUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchNodeStepsUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -506,7 +507,7 @@ func GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId str
|
|||||||
|
|
||||||
func GetNodeSteps(projectName, pipelineName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
func GetNodeSteps(projectName, pipelineName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server+GetNodeStepsUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId)
|
baseUrl := fmt.Sprintf(jenkins.Server+GetNodeStepsUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -519,7 +520,7 @@ func GetNodeSteps(projectName, pipelineName, runId, nodeId string, req *http.Req
|
|||||||
|
|
||||||
func ToJenkinsfile(req *http.Request) ([]byte, error) {
|
func ToJenkinsfile(req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server + ToJenkinsfileUrl)
|
baseUrl := fmt.Sprintf(jenkins.Server + ToJenkinsfileUrl)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -532,7 +533,7 @@ func ToJenkinsfile(req *http.Request) ([]byte, error) {
|
|||||||
|
|
||||||
func ToJson(req *http.Request) ([]byte, error) {
|
func ToJson(req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server + ToJsonUrl)
|
baseUrl := fmt.Sprintf(jenkins.Server + ToJsonUrl)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -544,8 +545,8 @@ func ToJson(req *http.Request) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetNotifyCommit(req *http.Request) ([]byte, error) {
|
func GetNotifyCommit(req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server + GetNotifyCommitUrl + req.URL.RawQuery)
|
baseUrl := fmt.Sprint(jenkins.Server, GetNotifyCommitUrl, req.URL.RawQuery)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
req.Method = "GET"
|
req.Method = "GET"
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
@@ -558,8 +559,8 @@ func GetNotifyCommit(req *http.Request) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GithubWebhook(req *http.Request) ([]byte, error) {
|
func GithubWebhook(req *http.Request) ([]byte, error) {
|
||||||
baseUrl := fmt.Sprintf(jenkins.Server + GithubWebhookUrl + req.URL.RawQuery)
|
baseUrl := fmt.Sprint(jenkins.Server, GithubWebhookUrl, req.URL.RawQuery)
|
||||||
log.Infof("Jenkins-url: " + baseUrl)
|
log.Info("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -572,7 +573,7 @@ func GithubWebhook(req *http.Request) ([]byte, error) {
|
|||||||
|
|
||||||
func GetBranchNodesDetail(projectName, pipelineName, branchName, runId string, req *http.Request) ([]NodesDetail, error) {
|
func GetBranchNodesDetail(projectName, pipelineName, branchName, runId string, req *http.Request) ([]NodesDetail, error) {
|
||||||
getNodesUrl := fmt.Sprintf(jenkins.Server+GetBranchPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
getNodesUrl := fmt.Sprintf(jenkins.Server+GetBranchPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
||||||
log.Infof("getNodesUrl: " + getNodesUrl)
|
log.Info("getNodesUrl: " + getNodesUrl)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var nodesDetails []NodesDetail
|
var nodesDetails []NodesDetail
|
||||||
stepChan := make(chan *NodesStepsIndex, channelMaxCapacity)
|
stepChan := make(chan *NodesStepsIndex, channelMaxCapacity)
|
||||||
@@ -619,7 +620,7 @@ func GetBranchNodesDetail(projectName, pipelineName, branchName, runId string, r
|
|||||||
|
|
||||||
func GetNodesDetail(projectName, pipelineName, runId string, req *http.Request) ([]NodesDetail, error) {
|
func GetNodesDetail(projectName, pipelineName, runId string, req *http.Request) ([]NodesDetail, error) {
|
||||||
getNodesUrl := fmt.Sprintf(jenkins.Server+GetPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
getNodesUrl := fmt.Sprintf(jenkins.Server+GetPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||||
log.Infof("getNodesUrl: " + getNodesUrl)
|
log.Info("getNodesUrl: " + getNodesUrl)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var nodesDetails []NodesDetail
|
var nodesDetails []NodesDetail
|
||||||
stepChan := make(chan *NodesStepsIndex, channelMaxCapacity)
|
stepChan := make(chan *NodesStepsIndex, channelMaxCapacity)
|
||||||
@@ -698,6 +699,7 @@ func jenkinsClient(baseUrl string, req *http.Request) ([]byte, http.Header, erro
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode >= http.StatusBadRequest {
|
if resp.StatusCode >= http.StatusBadRequest {
|
||||||
|
log.Errorf("%+v", string(resBody))
|
||||||
jkerr := new(JkError)
|
jkerr := new(JkError)
|
||||||
jkerr.Code = resp.StatusCode
|
jkerr.Code = resp.StatusCode
|
||||||
jkerr.Message = http.StatusText(resp.StatusCode)
|
jkerr.Message = http.StatusText(resp.StatusCode)
|
||||||
|
|||||||
Reference in New Issue
Block a user