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 e266041fb feat: add finished_date to cicd_deployment_commits table
(#5005)
e266041fb is described below
commit e266041fbc2e01623bc44729b107933884a79225
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Apr 23 15:31:51 2023 +0800
feat: add finished_date to cicd_deployment_commits table (#5005)
* feat: add finished_date to cicd_deployment_commits table
* refactor: assign values in a more consistent way
---
.../domainlayer/devops/cicd_deployment_commit.go | 1 +
.../20230411_add_cicd_deployment_commits.go | 4 ++--
.../migrationscripts/archived/cicd_deployment.go | 1 +
.../plugins/bitbucket/tasks/deployment_convertor.go | 19 ++++++++++---------
.../dora/tasks/deployment_commits_generator.go | 1 +
backend/plugins/webhook/api/deployments.go | 1 +
6 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/backend/core/models/domainlayer/devops/cicd_deployment_commit.go
b/backend/core/models/domainlayer/devops/cicd_deployment_commit.go
index 03f5dc898..f412e2b97 100644
--- a/backend/core/models/domainlayer/devops/cicd_deployment_commit.go
+++ b/backend/core/models/domainlayer/devops/cicd_deployment_commit.go
@@ -33,6 +33,7 @@ type CicdDeploymentCommit struct {
Environment string `gorm:"type:varchar(255)"`
CreatedDate time.Time
StartedDate *time.Time
+ FinishedDate *time.Time
DurationSec *uint64
CommitSha string
`gorm:"primaryKey;type:varchar(255)"`
RefName string `gorm:"type:varchar(255)"` // to
delete?
diff --git
a/backend/core/models/migrationscripts/20230411_add_cicd_deployment_commits.go
b/backend/core/models/migrationscripts/20230411_add_cicd_deployment_commits.go
index 0c4c16f3d..ff06ec51b 100644
---
a/backend/core/models/migrationscripts/20230411_add_cicd_deployment_commits.go
+++
b/backend/core/models/migrationscripts/20230411_add_cicd_deployment_commits.go
@@ -37,9 +37,9 @@ func (*addCicdDeploymentCommits) Up(basicRes
context.BasicRes) errors.Error {
}
func (*addCicdDeploymentCommits) Version() uint64 {
- return 20230411150701
+ return 20230411150702
}
func (*addCicdDeploymentCommits) Name() string {
- return "Rename cicd_pipeline_commits repo to repo_url"
+ return "add cicd_deployment_commits table"
}
diff --git a/backend/core/models/migrationscripts/archived/cicd_deployment.go
b/backend/core/models/migrationscripts/archived/cicd_deployment.go
index 53f0c888b..627cd6c55 100644
--- a/backend/core/models/migrationscripts/archived/cicd_deployment.go
+++ b/backend/core/models/migrationscripts/archived/cicd_deployment.go
@@ -31,6 +31,7 @@ type CicdDeploymentCommit struct {
Environment string `gorm:"type:varchar(255)"`
CreatedDate time.Time
StartedDate *time.Time
+ FinishedDate *time.Time
DurationSec *uint64
CommitSha string
`gorm:"primaryKey;type:varchar(255)"`
RefName string `gorm:"type:varchar(255)"`
diff --git a/backend/plugins/bitbucket/tasks/deployment_convertor.go
b/backend/plugins/bitbucket/tasks/deployment_convertor.go
index d4274ddc5..04e98682c 100644
--- a/backend/plugins/bitbucket/tasks/deployment_convertor.go
+++ b/backend/plugins/bitbucket/tasks/deployment_convertor.go
@@ -25,7 +25,7 @@ import (
"github.com/apache/incubator-devlake/core/models/domainlayer"
"github.com/apache/incubator-devlake/core/models/domainlayer/devops"
"github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
- plugin "github.com/apache/incubator-devlake/core/plugin"
+ "github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/bitbucket/models"
)
@@ -96,14 +96,15 @@ func ConvertDeployments(taskCtx plugin.SubTaskContext)
errors.Error {
Done: []string{"COMPLETED",
"UNDEPLOYED"},
Default: devops.IN_PROGRESS,
}, bitbucketDeployment.Status),
- Environment: bitbucketDeployment.Environment,
- CreatedDate: *bitbucketDeployment.CreatedOn,
- StartedDate: bitbucketDeployment.StartedOn,
- DurationSec: duration,
- CommitSha: bitbucketDeployment.CommitSha,
- RefName: bitbucketDeployment.RefName,
- RepoId: repoId,
- RepoUrl: repo.HTMLUrl,
+ Environment: bitbucketDeployment.Environment,
+ CreatedDate: *bitbucketDeployment.CreatedOn,
+ StartedDate: bitbucketDeployment.StartedOn,
+ FinishedDate: bitbucketDeployment.CompletedOn,
+ DurationSec: duration,
+ CommitSha: bitbucketDeployment.CommitSha,
+ RefName: bitbucketDeployment.RefName,
+ RepoId: repoId,
+ RepoUrl: repo.HTMLUrl,
}
return []interface{}{domainDeployCommit}, nil
},
diff --git a/backend/plugins/dora/tasks/deployment_commits_generator.go
b/backend/plugins/dora/tasks/deployment_commits_generator.go
index aebe18b65..f8f1cef7d 100644
--- a/backend/plugins/dora/tasks/deployment_commits_generator.go
+++ b/backend/plugins/dora/tasks/deployment_commits_generator.go
@@ -117,6 +117,7 @@ func GenerateDeploymentCommits(taskCtx
plugin.SubTaskContext) errors.Error {
Status: pipelineCommit.Status,
Environment: pipelineCommit.Environment,
CreatedDate: *pipelineCommit.CreatedDate,
+ FinishedDate: pipelineCommit.FinishedDate,
DurationSec: pipelineCommit.DurationSec,
CommitSha: pipelineCommit.CommitSha,
RefName: pipelineCommit.Branch,
diff --git a/backend/plugins/webhook/api/deployments.go
b/backend/plugins/webhook/api/deployments.go
index c9fbfd123..4b8069201 100644
--- a/backend/plugins/webhook/api/deployments.go
+++ b/backend/plugins/webhook/api/deployments.go
@@ -117,6 +117,7 @@ func PostDeploymentCicdTask(input *plugin.ApiResourceInput)
(*plugin.ApiResource
Environment: request.Environment,
CreatedDate: *request.CreatedDate,
StartedDate: request.StartedDate,
+ FinishedDate: request.FinishedDate,
DurationSec: &duration,
CommitSha: request.CommitSha,
RefName: request.RefName,