This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 1e6bb1dcd fix(jenkins): scope multi-branch build collection to current 
project (#8430) (#8781)
1e6bb1dcd is described below

commit 1e6bb1dcdf5941b46ae2686496239faaa5f86e87
Author: AvivGuiser <[email protected]>
AuthorDate: Mon Mar 23 16:30:30 2026 +0200

    fix(jenkins): scope multi-branch build collection to current project 
(#8430) (#8781)
    
    The branch jobs query in collectMultiBranchJobApiBuilds selected all
    WorkflowJob entries across all multi-branch pipelines for a connection,
    causing builds to be duplicated and misattributed. Filter by
    _raw_data_params to collect only the current project's branch jobs.
    
    Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
---
 backend/plugins/jenkins/tasks/build_collector.go | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/backend/plugins/jenkins/tasks/build_collector.go 
b/backend/plugins/jenkins/tasks/build_collector.go
index 0d792c614..a1ae74987 100644
--- a/backend/plugins/jenkins/tasks/build_collector.go
+++ b/backend/plugins/jenkins/tasks/build_collector.go
@@ -146,12 +146,17 @@ func collectMultiBranchJobApiBuilds(taskCtx 
plugin.SubTaskContext) errors.Error
        logger := taskCtx.GetLogger()
 
        // Jobs added through the multi-branch workflow have _raw_data_table 
set to "jenkins_api_jobs".
-       // This check works, but it's not very robust. It would be better to 
use a more explicit check like a "source" column.
+       // Filter by _raw_data_params to scope to only this multi-branch 
project's branch jobs,
+       // preventing cross-project data mixing when multiple multi-branch 
pipelines exist.
+       jobParams := plugin.MarshalScopeParams(JenkinsApiParams{
+               ConnectionId: data.Options.ConnectionId,
+               FullName:     data.Options.JobFullName,
+       })
        clauses := []dal.Clause{
                dal.Select("j.full_name,j.name,j.path,j.class,j.url"),
                dal.From("_tool_jenkins_jobs as j"),
-               dal.Where(`j.connection_id = ? and j.class = ? and 
j._raw_data_table = ?`,
-                       data.Options.ConnectionId, WORKFLOW_JOB, 
fmt.Sprintf("_raw_%s", RAW_JOB_TABLE)),
+               dal.Where(`j.connection_id = ? and j.class = ? and 
j._raw_data_table = ? and j._raw_data_params = ?`,
+                       data.Options.ConnectionId, WORKFLOW_JOB, 
fmt.Sprintf("_raw_%s", RAW_JOB_TABLE), jobParams),
        }
        cursor, err := db.Cursor(clauses...)
        if err != nil {

Reply via email to