You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2023/10/26 08:17:11 UTC

[incubator-devlake] branch main updated: fix: cicd deployment no data (#6338)

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

abeizn 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 03ea25cba fix: cicd deployment no data (#6338)
03ea25cba is described below

commit 03ea25cba66ddfb94356fa8d5f78c5dd283f9ca3
Author: abeizn <zi...@merico.dev>
AuthorDate: Thu Oct 26 03:17:07 2023 -0500

    fix: cicd deployment no data (#6338)
    
    * fix: cicd deployment no data
    
    * fix: some plugins get CicdDeploymentId
    
    * fix: remove some code
    
    * fix: bitbucket CicdDeploymentId
    
    * fix: ci lint
    
    * fix: gitlab CicdDeploymentId
---
 backend/plugins/bitbucket/tasks/deployment_convertor.go      |  8 ++++----
 backend/plugins/github_graphql/tasks/deployment_convertor.go |  4 +++-
 backend/plugins/gitlab/tasks/deployment_convertor.go         | 11 ++++++-----
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/backend/plugins/bitbucket/tasks/deployment_convertor.go b/backend/plugins/bitbucket/tasks/deployment_convertor.go
index 6cfdcee11..e4aeb95f4 100644
--- a/backend/plugins/bitbucket/tasks/deployment_convertor.go
+++ b/backend/plugins/bitbucket/tasks/deployment_convertor.go
@@ -67,7 +67,6 @@ func ConvertDeployments(taskCtx plugin.SubTaskContext) errors.Error {
 	defer cursor.Close()
 
 	idGen := didgen.NewDomainIdGenerator(&models.BitbucketDeployment{})
-	pipelineIdGen := didgen.NewDomainIdGenerator(&models.BitbucketPipeline{})
 
 	converter, err := api.NewDataConverter(api.DataConverterArgs{
 		InputRowType:       reflect.TypeOf(bitbucketDeploymentWithRefName{}),
@@ -85,9 +84,8 @@ func ConvertDeployments(taskCtx plugin.SubTaskContext) errors.Error {
 				DomainEntity: domainlayer.DomainEntity{
 					Id: idGen.Generate(data.Options.ConnectionId, bitbucketDeployment.BitbucketId),
 				},
-				CicdScopeId:      repoId,
-				CicdDeploymentId: pipelineIdGen.Generate(data.Options.ConnectionId, bitbucketDeployment.PipelineId),
-				Name:             bitbucketDeployment.Name,
+				CicdScopeId: repoId,
+				Name:        bitbucketDeployment.Name,
 				Result: devops.GetResult(&devops.ResultRule{
 					Failed:  []string{},
 					Success: []string{models.COMPLETED},
@@ -114,6 +112,8 @@ func ConvertDeployments(taskCtx plugin.SubTaskContext) errors.Error {
 				// So convert it to devlake's definition.
 				domainDeployCommit.Environment = devops.TESTING
 			}
+
+			domainDeployCommit.CicdDeploymentId = domainDeployCommit.Id
 			return []interface{}{domainDeployCommit, domainDeployCommit.ToDeployment()}, nil
 		},
 	})
diff --git a/backend/plugins/github_graphql/tasks/deployment_convertor.go b/backend/plugins/github_graphql/tasks/deployment_convertor.go
index 68be29d71..fbfd33277 100644
--- a/backend/plugins/github_graphql/tasks/deployment_convertor.go
+++ b/backend/plugins/github_graphql/tasks/deployment_convertor.go
@@ -19,6 +19,8 @@ package tasks
 
 import (
 	"fmt"
+	"reflect"
+
 	"github.com/apache/incubator-devlake/core/dal"
 	"github.com/apache/incubator-devlake/core/errors"
 	"github.com/apache/incubator-devlake/core/models/domainlayer"
@@ -27,7 +29,6 @@ import (
 	"github.com/apache/incubator-devlake/core/plugin"
 	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
 	githubModels "github.com/apache/incubator-devlake/plugins/github/models"
-	"reflect"
 )
 
 var _ plugin.SubTaskEntryPoint = ConvertDeployment
@@ -98,6 +99,7 @@ func ConvertDeployment(taskCtx plugin.SubTaskContext) errors.Error {
 				deploymentCommit.Environment = data.RegexEnricher.ReturnNameIfMatched(devops.PRODUCTION, githubDeployment.Environment)
 			}
 
+			deploymentCommit.CicdDeploymentId = deploymentCommit.Id
 			return []interface{}{
 				deploymentCommit,
 				deploymentCommit.ToDeployment(),
diff --git a/backend/plugins/gitlab/tasks/deployment_convertor.go b/backend/plugins/gitlab/tasks/deployment_convertor.go
index e2348a98e..480806adc 100644
--- a/backend/plugins/gitlab/tasks/deployment_convertor.go
+++ b/backend/plugins/gitlab/tasks/deployment_convertor.go
@@ -19,6 +19,8 @@ package tasks
 
 import (
 	"fmt"
+	"reflect"
+
 	"github.com/apache/incubator-devlake/core/dal"
 	"github.com/apache/incubator-devlake/core/errors"
 	"github.com/apache/incubator-devlake/core/models/domainlayer"
@@ -28,7 +30,6 @@ import (
 	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
 	"github.com/apache/incubator-devlake/plugins/gitlab/models"
 	"github.com/spf13/cast"
-	"reflect"
 )
 
 var _ plugin.SubTaskEntryPoint = ConvertDeployment
@@ -89,10 +90,9 @@ func ConvertDeployment(taskCtx plugin.SubTaskContext) errors.Error {
 				}
 			}
 			domainDeployCommit := &devops.CicdDeploymentCommit{
-				DomainEntity:     domainlayer.NewDomainEntity(idGen.Generate(data.Options.ConnectionId, data.Options.ProjectId, gitlabDeployment.DeploymentId)),
-				CicdScopeId:      projectIdGen.Generate(data.Options.ConnectionId, data.Options.ProjectId),
-				CicdDeploymentId: idGen.Generate(data.Options.ConnectionId, data.Options.ProjectId, gitlabDeployment.DeploymentId),
-				Name:             fmt.Sprintf("%s:%d", gitlabDeployment.Name, gitlabDeployment.DeploymentId),
+				DomainEntity: domainlayer.NewDomainEntity(idGen.Generate(data.Options.ConnectionId, data.Options.ProjectId, gitlabDeployment.DeploymentId)),
+				CicdScopeId:  projectIdGen.Generate(data.Options.ConnectionId, data.Options.ProjectId),
+				Name:         fmt.Sprintf("%s:%d", gitlabDeployment.Name, gitlabDeployment.DeploymentId),
 				Result: devops.GetResult(&devops.ResultRule{
 					Failed:  []string{"UNDEPLOYED", "failed"},
 					Success: []string{"COMPLETED", "success"},
@@ -123,6 +123,7 @@ func ConvertDeployment(taskCtx plugin.SubTaskContext) errors.Error {
 				domainDeployCommit.Environment = data.RegexEnricher.ReturnNameIfOmittedOrMatched(devops.PRODUCTION, gitlabDeployment.Environment)
 			}
 
+			domainDeployCommit.CicdDeploymentId = domainDeployCommit.Id
 			return []interface{}{
 				domainDeployCommit,
 				domainDeployCommit.ToDeployment(),