@@ -573,9 +573,9 @@ func addWebService(c *restful.Container) error {
|
|||||||
|
|
||||||
// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{}/runs/
|
// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{}/runs/
|
||||||
webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/run").
|
webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/run").
|
||||||
To(devopsapi.RunPipeline).
|
To(devopsapi.RunBranchPipeline).
|
||||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||||
Doc("Get pipeline artifacts.").
|
Doc("Run pipeline.").
|
||||||
Reads(devops.RunPayload{}).
|
Reads(devops.RunPayload{}).
|
||||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||||
@@ -583,6 +583,17 @@ func addWebService(c *restful.Container) error {
|
|||||||
Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}).
|
Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}).
|
||||||
Writes(devops.QueuedBlueRun{}))
|
Writes(devops.QueuedBlueRun{}))
|
||||||
|
|
||||||
|
// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/
|
||||||
|
webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/run").
|
||||||
|
To(devopsapi.RunPipeline).
|
||||||
|
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||||
|
Doc("Run pipeline.").
|
||||||
|
Reads(devops.RunPayload{}).
|
||||||
|
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||||
|
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||||
|
Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}).
|
||||||
|
Writes(devops.QueuedBlueRun{}))
|
||||||
|
|
||||||
// match /pipeline_status/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/?limit=
|
// match /pipeline_status/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/?limit=
|
||||||
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/status").
|
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/status").
|
||||||
To(devopsapi.GetBranchStepsStatus).
|
To(devopsapi.GetBranchStepsStatus).
|
||||||
|
|||||||
@@ -359,12 +359,26 @@ func ScanBranch(req *restful.Request, resp *restful.Response) {
|
|||||||
resp.Write(res)
|
resp.Write(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunPipeline(req *restful.Request, resp *restful.Response) {
|
func RunBranchPipeline(req *restful.Request, resp *restful.Response) {
|
||||||
projectName := req.PathParameter("projectName")
|
projectName := req.PathParameter("projectName")
|
||||||
pipelineName := req.PathParameter("pipelineName")
|
pipelineName := req.PathParameter("pipelineName")
|
||||||
branchName := req.PathParameter("branchName")
|
branchName := req.PathParameter("branchName")
|
||||||
|
|
||||||
res, err := devops.RunPipeline(projectName, pipelineName, branchName, req.Request)
|
res, err := devops.RunBranchPipeline(projectName, pipelineName, branchName, req.Request)
|
||||||
|
if err != nil {
|
||||||
|
parseErr(err, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.Header().Set(restful.HEADER_ContentType, restful.MIME_JSON)
|
||||||
|
resp.Write(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RunPipeline(req *restful.Request, resp *restful.Response) {
|
||||||
|
projectName := req.PathParameter("projectName")
|
||||||
|
pipelineName := req.PathParameter("pipelineName")
|
||||||
|
|
||||||
|
res, err := devops.RunPipeline(projectName, pipelineName, req.Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
parseErr(err, resp)
|
parseErr(err, resp)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -340,8 +340,21 @@ func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, er
|
|||||||
return resBody, err
|
return resBody, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunPipeline(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+RunPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName)
|
baseUrl := fmt.Sprintf(jenkins.Server+RunBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName)
|
||||||
|
log.Infof("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
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.Infof("Jenkins-url: " + baseUrl)
|
||||||
|
|
||||||
res, err := sendJenkinsRequest(baseUrl, req)
|
res, err := sendJenkinsRequest(baseUrl, req)
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ const (
|
|||||||
GetBranchPipeUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/"
|
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/%s/"
|
||||||
SearchPipelineUrl = "/blue/rest/search/?"
|
SearchPipelineUrl = "/blue/rest/search/?"
|
||||||
RunPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/"
|
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/"
|
GetPipelineRunUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/"
|
||||||
GetPipeBranchRunUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/"
|
GetPipeBranchRunUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/"
|
||||||
SearchPipelineRunUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/?"
|
SearchPipelineRunUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/runs/?"
|
||||||
|
|||||||
Reference in New Issue
Block a user