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 cf46dfc00 fix(bitbucket): normalise
cicd_deployment_commits.environment field (#6333)
cf46dfc00 is described below
commit cf46dfc00e5b9737a251b8a9dc0a125f16ad9f5e
Author: Lynwee <[email protected]>
AuthorDate: Wed Oct 25 21:14:57 2023 +0800
fix(bitbucket): normalise cicd_deployment_commits.environment field (#6333)
---
backend/plugins/bitbucket/tasks/deployment_convertor.go | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/backend/plugins/bitbucket/tasks/deployment_convertor.go
b/backend/plugins/bitbucket/tasks/deployment_convertor.go
index ab93888d0..6cfdcee11 100644
--- a/backend/plugins/bitbucket/tasks/deployment_convertor.go
+++ b/backend/plugins/bitbucket/tasks/deployment_convertor.go
@@ -19,6 +19,7 @@ package tasks
import (
"reflect"
+ "strings"
"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
@@ -96,7 +97,7 @@ func ConvertDeployments(taskCtx plugin.SubTaskContext)
errors.Error {
Done: []string{models.COMPLETED},
Default: bitbucketDeployment.Status,
}, bitbucketDeployment.Status),
- Environment: bitbucketDeployment.Environment,
// or bitbucketDeployment.EnvironmentType, they are same so far.
+ Environment:
strings.ToUpper(bitbucketDeployment.Environment), // or
bitbucketDeployment.EnvironmentType, they are same so far.
CreatedDate: *bitbucketDeployment.CreatedOn,
StartedDate: bitbucketDeployment.StartedOn,
FinishedDate: bitbucketDeployment.CompletedOn,
@@ -106,6 +107,13 @@ func ConvertDeployments(taskCtx plugin.SubTaskContext)
errors.Error {
RepoId: repoId,
RepoUrl: repo.HTMLUrl,
}
+ if domainDeployCommit.Environment == devops.TEST {
+ // Theoretically, environment cannot be "Test"
according to
+ //
https://developer.atlassian.com/server/bitbucket/rest/v814/api-group-builds-and-deployments/#api-api-latest-projects-projectkey-repos-repositoryslug-commits-commitid-deployments-get
+ // but in practice, we found environment is
"Test".
+ // So convert it to devlake's definition.
+ domainDeployCommit.Environment = devops.TESTING
+ }
return []interface{}{domainDeployCommit,
domainDeployCommit.ToDeployment()}, nil
},
})