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

mappjzc 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 d1e716607 fix: missing repo_url (#4909)
d1e716607 is described below

commit d1e71660772b3e62027c29c46a4427be6a352ded
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Apr 12 23:05:47 2023 +0800

    fix: missing repo_url (#4909)
---
 .../plugins/bamboo/e2e/plan_build_commits_test.go  | 62 ++++++++++++++++++++++
 backend/plugins/bamboo/e2e/plan_build_test.go      |  7 ---
 .../_tool_bamboo_plan_build_commits.csv            |  3 ++
 .../e2e/snapshot_tables/cicd_pipeline_commits.csv  |  4 +-
 .../plugins/bamboo/tasks/plan_commit_convertor.go  |  1 +
 5 files changed, 69 insertions(+), 8 deletions(-)

diff --git a/backend/plugins/bamboo/e2e/plan_build_commits_test.go 
b/backend/plugins/bamboo/e2e/plan_build_commits_test.go
new file mode 100644
index 000000000..cf695f845
--- /dev/null
+++ b/backend/plugins/bamboo/e2e/plan_build_commits_test.go
@@ -0,0 +1,62 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package e2e
+
+import (
+       "testing"
+
+       "github.com/apache/incubator-devlake/core/models/domainlayer/devops"
+       "github.com/apache/incubator-devlake/helpers/e2ehelper"
+       "github.com/apache/incubator-devlake/plugins/bamboo/impl"
+       "github.com/apache/incubator-devlake/plugins/bamboo/models"
+       "github.com/apache/incubator-devlake/plugins/bamboo/tasks"
+)
+
+func TestBambooPlanBuildCommitsDataFlow(t *testing.T) {
+
+       var bamboo impl.Bamboo
+       dataflowTester := e2ehelper.NewDataFlowTester(t, "bamboo", bamboo)
+
+       taskData := &tasks.BambooTaskData{
+               Options: &models.BambooOptions{
+                       ConnectionId: 3,
+                       ProjectKey:   "TEST1",
+                       BambooTransformationRule: 
&models.BambooTransformationRule{
+                               DeploymentPattern: "(?i)compile",
+                               ProductionPattern: "(?i)compile",
+                       },
+               },
+       }
+       
dataflowTester.ImportCsvIntoTabler("./snapshot_tables/_tool_bamboo_plan_build_commits.csv",
 &models.BambooPlanBuildVcsRevision{})
+       
dataflowTester.ImportCsvIntoTabler("./snapshot_tables/_tool_bamboo_plan_builds.csv",
 &models.BambooPlanBuild{})
+
+       // verify extraction
+       dataflowTester.FlushTabler(&devops.CiCDPipelineCommit{})
+       dataflowTester.Subtask(tasks.ConvertPlanVcsMeta, taskData)
+       dataflowTester.VerifyTable(
+               devops.CiCDPipelineCommit{},
+               "./snapshot_tables/cicd_pipeline_commits.csv",
+               e2ehelper.ColumnWithRawData(
+                       "pipeline_id",
+                       "commit_sha",
+                       "branch",
+                       "repo_id",
+                       "repo_url",
+               ),
+       )
+}
diff --git a/backend/plugins/bamboo/e2e/plan_build_test.go 
b/backend/plugins/bamboo/e2e/plan_build_test.go
index 9229b7057..67daa0492 100644
--- a/backend/plugins/bamboo/e2e/plan_build_test.go
+++ b/backend/plugins/bamboo/e2e/plan_build_test.go
@@ -96,17 +96,10 @@ func TestBambooPlanBuildDataFlow(t *testing.T) {
        dataflowTester.FlushTabler(&devops.CICDPipeline{})
        dataflowTester.FlushTabler(&devops.CiCDPipelineCommit{})
 
-       dataflowTester.Subtask(tasks.ConvertPlanBuildsMeta, taskData)
        dataflowTester.Subtask(tasks.ConvertPlanBuildsMeta, taskData)
 
        dataflowTester.VerifyTableWithOptions(&devops.CICDPipeline{}, 
e2ehelper.TableOptions{
                CSVRelPath:  "./snapshot_tables/cicd_pipelines.csv",
                IgnoreTypes: []interface{}{common.NoPKModel{}},
        })
-
-       dataflowTester.VerifyTableWithOptions(&devops.CiCDPipelineCommit{}, 
e2ehelper.TableOptions{
-               CSVRelPath:  "./snapshot_tables/cicd_pipeline_commits.csv",
-               IgnoreTypes: []interface{}{common.NoPKModel{}},
-       })
-
 }
diff --git 
a/backend/plugins/bamboo/e2e/snapshot_tables/_tool_bamboo_plan_build_commits.csv
 
b/backend/plugins/bamboo/e2e/snapshot_tables/_tool_bamboo_plan_build_commits.csv
new file mode 100644
index 000000000..20d8b4b49
--- /dev/null
+++ 
b/backend/plugins/bamboo/e2e/snapshot_tables/_tool_bamboo_plan_build_commits.csv
@@ -0,0 +1,3 @@
+"connection_id","plan_build_key","repository_id","repository_name","vcs_revision_key","created_at","updated_at","_raw_data_params","_raw_data_table","_raw_data_id","_raw_data_remark"
+3,TEST1-TEST2-1,1736707,"devlake-website","207fc4666c4d356b474ed951ffe38cc2ad97499e","2023-04-12
 09:19:52.190","2023-04-12 
09:19:53.600","{""connectionId"":3,""ProjectKey"":""TEST2""}","_raw_bamboo_api_job_build",3,""
+3,TEST1-TEST2-1,1736708,devlake-test,"caab17b6dc3532b7f78f418a192c050320a30e46","2023-04-12
 09:19:52.190","2023-04-12 
09:19:52.190","{""connectionId"":3,""ProjectKey"":""TEST2""}","_raw_bamboo_api_plan_build",15,""
diff --git 
a/backend/plugins/bamboo/e2e/snapshot_tables/cicd_pipeline_commits.csv 
b/backend/plugins/bamboo/e2e/snapshot_tables/cicd_pipeline_commits.csv
index ff994bc63..fbdeddfd9 100644
--- a/backend/plugins/bamboo/e2e/snapshot_tables/cicd_pipeline_commits.csv
+++ b/backend/plugins/bamboo/e2e/snapshot_tables/cicd_pipeline_commits.csv
@@ -1 +1,3 @@
-pipeline_id,commit_sha,branch,repo_id,repo_url
+pipeline_id,commit_sha,branch,repo_id,repo_url,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
+bamboo:BambooPlanBuild:3:TEST1-TEST2-1,207fc4666c4d356b474ed951ffe38cc2ad97499e,,,devlake-website,"{""connectionId"":3,""ProjectKey"":""TEST2""}",_raw_bamboo_api_job_build,3,
+bamboo:BambooPlanBuild:3:TEST1-TEST2-1,caab17b6dc3532b7f78f418a192c050320a30e46,,,devlake-test,"{""connectionId"":3,""ProjectKey"":""TEST2""}",_raw_bamboo_api_plan_build,15,
diff --git a/backend/plugins/bamboo/tasks/plan_commit_convertor.go 
b/backend/plugins/bamboo/tasks/plan_commit_convertor.go
index c9ac60fa3..aed4c95eb 100644
--- a/backend/plugins/bamboo/tasks/plan_commit_convertor.go
+++ b/backend/plugins/bamboo/tasks/plan_commit_convertor.go
@@ -67,6 +67,7 @@ func ConvertPlanVcs(taskCtx plugin.SubTaskContext) 
errors.Error {
                        domainPlanVcs := &devops.CiCDPipelineCommit{
                                PipelineId: 
planBuildIdGen.Generate(data.Options.ConnectionId, line.PlanBuildKey),
                                CommitSha:  line.VcsRevisionKey,
+                               RepoUrl:    line.RepositoryName,
                        }
                        domainPlanVcs.RepoId = repoMap[line.RepositoryId]
                        return []interface{}{

Reply via email to