Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions pkg/pipeline/CiHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ import (
"context"
"errors"
"fmt"
"regexp"
"slices"
"strconv"
"strings"
"time"

"github.com/devtron-labs/common-lib/utils"
"github.com/devtron-labs/common-lib/utils/workFlow"
cdWorkflowBean "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
Expand All @@ -32,11 +38,6 @@ import (
util2 "github.com/devtron-labs/devtron/pkg/pipeline/util"
"github.com/devtron-labs/devtron/pkg/pipeline/workflowStatus"
"github.com/devtron-labs/devtron/pkg/workflow/workflowStatusLatest"
"regexp"
"slices"
"strconv"
"strings"
"time"

"github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
bean2 "github.com/devtron-labs/devtron/api/bean"
Expand Down Expand Up @@ -1064,6 +1065,7 @@ func (impl *CiHandlerImpl) FetchCiStatusForTriggerViewForEnvironment(request res

linkedPipelineDetails := make(map[int]*pipelineConfig.CiPipeline) // linkedPipelineId -> pipeline object
parentToLinkedMap := make(map[int][]int) // parentPipelineId -> []linkedPipelineId
directCiPipelineIds := make(map[int]bool) // pipeline IDs that are direct (non-linked) CI pipelines in this env

for _, ciPipeline := range ciPipelines {
appObject := objects[ciPipeline.Id] // here only app permission have to check
Expand All @@ -1079,6 +1081,8 @@ func (impl *CiHandlerImpl) FetchCiStatusForTriggerViewForEnvironment(request res
linkedPipelineDetails[ciPipeline.Id] = ciPipeline
// Add to slice of linked pipelines for this parent
parentToLinkedMap[ciPipelineId] = append(parentToLinkedMap[ciPipelineId], ciPipeline.Id)
} else {
directCiPipelineIds[ciPipelineId] = true
}
}

Expand Down Expand Up @@ -1107,6 +1111,12 @@ func (impl *CiHandlerImpl) FetchCiStatusForTriggerViewForEnvironment(request res
ciWorkflowStatus := adapter.GetCiWorkflowStatusForLinkedCiPipeline(linkedPipelineId, linkedPipelineDetails[linkedPipelineId].Name, ciWorkflow)
ciWorkflowStatuses = append(ciWorkflowStatuses, ciWorkflowStatus)
}
// parent pipeline itself also needs a status entry when it is a direct CI pipeline
// in this env (App A's CI that App B links to — both have CD in the same env)
if directCiPipelineIds[ciWorkflow.CiPipelineId] {
ciWorkflowStatus := adapter.GetCiWorkflowStatusFromCiWorkflow(ciWorkflow)
ciWorkflowStatuses = append(ciWorkflowStatuses, ciWorkflowStatus)
}
} else {
ciWorkflowStatus := adapter.GetCiWorkflowStatusFromCiWorkflow(ciWorkflow)
ciWorkflowStatuses = append(ciWorkflowStatuses, ciWorkflowStatus)
Expand Down
Loading