@@ -68,10 +68,11 @@ func SearchPipelines(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)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+SearchPipelineRunUrl, projectName, pipelineName)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl+req.URL.RawQuery, req)
|
||||
if err != nil {
|
||||
log.Error(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) {
|
||||
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)
|
||||
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) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -106,35 +107,36 @@ 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)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||
resBody, header, err := jenkinsClient(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)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||
resBody, header, err := jenkinsClient(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) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+ValidateUrl, scmId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -147,7 +149,7 @@ func Validate(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)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -160,7 +162,7 @@ func GetSCMOrg(scmId 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)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -173,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) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -186,7 +188,7 @@ func StopBranchPipeline(projectName, pipelineName, branchName, runId string, req
|
||||
|
||||
func StopPipeline(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -199,7 +201,7 @@ func StopPipeline(projectName, pipelineName, runId string, req *http.Request) ([
|
||||
|
||||
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)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -212,7 +214,7 @@ func ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, r
|
||||
|
||||
func ReplayPipeline(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -225,7 +227,7 @@ func ReplayPipeline(projectName, pipelineName, runId string, req *http.Request)
|
||||
|
||||
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)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -238,7 +240,7 @@ func GetBranchRunLog(projectName, pipelineName, branchName, runId string, req *h
|
||||
|
||||
func GetRunLog(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -251,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) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -264,7 +266,7 @@ func GetBranchArtifacts(projectName, pipelineName, branchName, runId string, req
|
||||
|
||||
func GetArtifacts(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -276,10 +278,10 @@ func GetArtifacts(projectName, pipelineName, runId string, req *http.Request) ([
|
||||
}
|
||||
|
||||
func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchUrl+req.URL.RawQuery, projectName, pipelineName)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchUrl, projectName, pipelineName)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
res, err := sendJenkinsRequest(baseUrl+req.URL.RawQuery, req)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return nil, err
|
||||
@@ -290,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) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -303,7 +305,7 @@ func CheckBranchPipeline(projectName, pipelineName, branchName, runId, nodeId, s
|
||||
|
||||
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)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -316,7 +318,7 @@ func CheckPipeline(projectName, pipelineName, runId, nodeId, stepId string, req
|
||||
|
||||
func GetConsoleLog(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -329,7 +331,7 @@ func GetConsoleLog(projectName, pipelineName string, req *http.Request) ([]byte,
|
||||
|
||||
func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -342,7 +344,7 @@ func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, er
|
||||
|
||||
func RunBranchPipeline(projectName, pipelineName, branchName string, req *http.Request) ([]byte, error) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -355,7 +357,7 @@ func RunBranchPipeline(projectName, pipelineName, branchName string, req *http.R
|
||||
|
||||
func RunPipeline(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -368,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) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -381,7 +383,7 @@ func GetBranchStepsStatus(projectName, pipelineName, branchName, runId, nodeId s
|
||||
|
||||
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)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -394,7 +396,7 @@ func GetStepsStatus(projectName, pipelineName, runId, nodeId string, req *http.R
|
||||
|
||||
func GetCrumb(req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server + GetCrumbUrl)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -407,7 +409,7 @@ func GetCrumb(req *http.Request) ([]byte, error) {
|
||||
|
||||
func CheckScriptCompile(req *http.Request) ([]byte, error) {
|
||||
baseUrl := jenkins.Server + CheckScriptCompileUrl
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
req.SetBasicAuth(jenkins.Requester.BasicAuth.Username, jenkins.Requester.BasicAuth.Password)
|
||||
|
||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||
@@ -420,12 +422,19 @@ func CheckScriptCompile(req *http.Request) ([]byte, error) {
|
||||
}
|
||||
|
||||
func CheckCron(req *http.Request) (*CheckCronRes, error) {
|
||||
baseUrl := jenkins.Server + CheckCronUrl + req.URL.RawQuery
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
req.SetBasicAuth(jenkins.Requester.BasicAuth.Username, jenkins.Requester.BasicAuth.Password)
|
||||
var res = new(CheckCronRes)
|
||||
newurl, err := url.Parse(jenkins.Server + CheckCronUrl + req.URL.RawQuery)
|
||||
|
||||
resp, err := http.Get(baseUrl)
|
||||
reqJenkins := &http.Request{
|
||||
Method: http.MethodGet,
|
||||
URL: newurl,
|
||||
Header: http.Header{},
|
||||
}
|
||||
var res = new(CheckCronRes)
|
||||
client := &http.Client{Timeout: 30 * time.Second}
|
||||
|
||||
reqJenkins.SetBasicAuth(jenkins.Requester.BasicAuth.Username, jenkins.Requester.BasicAuth.Password)
|
||||
|
||||
resp, err := client.Do(reqJenkins)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return res, err
|
||||
@@ -446,7 +455,7 @@ func CheckCron(req *http.Request) (*CheckCronRes, error) {
|
||||
|
||||
func GetPipelineRun(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipelineRunUrl, projectName, pipelineName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -459,7 +468,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.Server+GetBranchPipeUrl, projectName, pipelineName, branchName)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -472,7 +481,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.Server+GetPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -485,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) {
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -498,7 +507,7 @@ func GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId str
|
||||
|
||||
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)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -511,7 +520,7 @@ func GetNodeSteps(projectName, pipelineName, runId, nodeId string, req *http.Req
|
||||
|
||||
func ToJenkinsfile(req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server + ToJenkinsfileUrl)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -524,7 +533,7 @@ func ToJenkinsfile(req *http.Request) ([]byte, error) {
|
||||
|
||||
func ToJson(req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server + ToJsonUrl)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -536,8 +545,8 @@ func ToJson(req *http.Request) ([]byte, error) {
|
||||
}
|
||||
|
||||
func GetNotifyCommit(req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server + GetNotifyCommitUrl + req.URL.RawQuery)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
baseUrl := fmt.Sprint(jenkins.Server, GetNotifyCommitUrl, req.URL.RawQuery)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
req.Method = "GET"
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
@@ -550,8 +559,8 @@ func GetNotifyCommit(req *http.Request) ([]byte, error) {
|
||||
}
|
||||
|
||||
func GithubWebhook(req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server + GithubWebhookUrl + req.URL.RawQuery)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
baseUrl := fmt.Sprint(jenkins.Server, GithubWebhookUrl, req.URL.RawQuery)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -564,7 +573,7 @@ func GithubWebhook(req *http.Request) ([]byte, 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)
|
||||
log.Infof("getNodesUrl: " + getNodesUrl)
|
||||
log.Info("getNodesUrl: " + getNodesUrl)
|
||||
var wg sync.WaitGroup
|
||||
var nodesDetails []NodesDetail
|
||||
stepChan := make(chan *NodesStepsIndex, channelMaxCapacity)
|
||||
@@ -611,7 +620,7 @@ func GetBranchNodesDetail(projectName, pipelineName, branchName, runId string, r
|
||||
|
||||
func GetNodesDetail(projectName, pipelineName, runId string, req *http.Request) ([]NodesDetail, error) {
|
||||
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 nodesDetails []NodesDetail
|
||||
stepChan := make(chan *NodesStepsIndex, channelMaxCapacity)
|
||||
@@ -658,10 +667,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 +692,22 @@ 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 {
|
||||
log.Errorf("%+v", string(resBody))
|
||||
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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,43 +19,45 @@ 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/?"
|
||||
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/?"
|
||||
GetNodeStepsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/nodes/%s/steps/?"
|
||||
ValidateUrl = "/blue/rest/organizations/jenkins/scm/%s/validate"
|
||||
GetSCMOrgUrl = "/blue/rest/organizations/jenkins/scm/%s/organizations/?"
|
||||
GetOrgRepoUrl = "/blue/rest/organizations/jenkins/scm/%s/organizations/%s/repositories/?"
|
||||
GetConsoleLogUrl = "/job/%s/job/%s/indexing/consoleText"
|
||||
ScanBranchUrl = "/job/%s/job/%s/build?"
|
||||
GetCrumbUrl = "/crumbIssuer/api/json/"
|
||||
CheckScriptCompileUrl = "/job/init-job/descriptorByName/org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition/checkScriptCompile"
|
||||
CheckCronUrl = "/job/init-job/descriptorByName/hudson.triggers.TimerTrigger/checkSpec?"
|
||||
ToJenkinsfileUrl = "/pipeline-model-converter/toJenkinsfile"
|
||||
ToJsonUrl = "/pipeline-model-converter/toJson"
|
||||
GetNotifyCommitUrl = "/git/notifyCommit/?"
|
||||
GithubWebhookUrl = "/github-webhook/"
|
||||
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/pipelines/%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/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/?"
|
||||
GetNodeStepsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/?"
|
||||
ValidateUrl = "/blue/rest/organizations/jenkins/scm/%s/validate"
|
||||
GetSCMOrgUrl = "/blue/rest/organizations/jenkins/scm/%s/organizations/?"
|
||||
GetOrgRepoUrl = "/blue/rest/organizations/jenkins/scm/%s/organizations/%s/repositories/?"
|
||||
GetConsoleLogUrl = "/job/%s/job/%s/indexing/consoleText"
|
||||
ScanBranchUrl = "/job/%s/job/%s/build?"
|
||||
GetCrumbUrl = "/crumbIssuer/api/json/"
|
||||
CheckScriptCompileUrl = "/job/init-job/descriptorByName/org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition/checkScriptCompile"
|
||||
CheckCronUrl = "/job/init-job/descriptorByName/hudson.triggers.TimerTrigger/checkSpec?"
|
||||
ToJenkinsfileUrl = "/pipeline-model-converter/toJenkinsfile"
|
||||
ToJsonUrl = "/pipeline-model-converter/toJson"
|
||||
GetNotifyCommitUrl = "/git/notifyCommit/?"
|
||||
GithubWebhookUrl = "/github-webhook/"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user