Fix Pipeline input failed in multi-branch mode

Signed-off-by: rick <1450685+LinuxSuRen@users.noreply.github.com>
This commit is contained in:
rick
2021-03-17 16:39:58 +08:00
parent 3a79df0da5
commit bc0be03603
5 changed files with 15 additions and 7 deletions

View File

@@ -104,9 +104,9 @@ func NewController(client clientset.Interface,
devopsInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: v.enqueuePipeline,
UpdateFunc: func(oldObj, newObj interface{}) {
old := oldObj.(*devopsv1alpha3.Pipeline)
new := newObj.(*devopsv1alpha3.Pipeline)
if old.ResourceVersion == new.ResourceVersion {
oldPipeline := oldObj.(*devopsv1alpha3.Pipeline)
newPipeline := newObj.(*devopsv1alpha3.Pipeline)
if oldPipeline.ResourceVersion == newPipeline.ResourceVersion {
return
}
v.enqueuePipeline(newObj)

View File

@@ -379,10 +379,18 @@ func (h *ProjectPipelineHandler) hasSubmitPermission(req *restful.Request) (hasP
runId := req.PathParameter("run")
nodeId := req.PathParameter("node")
stepId := req.PathParameter("step")
branchName := req.PathParameter("branch")
// check if current user can approve this input
var res []clientDevOps.NodesDetail
if res, err = h.devopsOperator.GetNodesDetail(pipeParam.ProjectName, pipeParam.Name, runId, httpReq); err == nil {
if branchName == "" {
res, err = h.devopsOperator.GetNodesDetail(pipeParam.ProjectName, pipeParam.Name, runId, httpReq)
} else {
res, err = h.devopsOperator.GetBranchNodesDetail(pipeParam.ProjectName, pipeParam.Name, branchName, runId, httpReq)
}
if err == nil {
h.approvableCheck(res, parsePipelineParam(req))
for _, node := range res {

View File

@@ -112,7 +112,7 @@ func (p *Pipeline) ListPipelines() (*devops.PipelineList, error) {
}
klog.Errorf("API '%s' request response code is '%d'", p.Path, jErr.Code)
} else {
err = fmt.Errorf("unknow errors happend when coumunicate with Jenkins")
err = fmt.Errorf("unknow errors happend when communicate with Jenkins")
}
return nil, err
}