Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cherry-pick #7130 fix(dora): add started_date when generating cicd_deployment_commits #7131

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions backend/plugins/dora/tasks/deployment_commits_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type pipelineCommitEx struct {
OriginalResult string
DurationSec *float64
QueuedDurationSec *float64
StartedDate *time.Time
CreatedDate *time.Time
FinishedDate *time.Time
Environment string
Expand All @@ -71,6 +72,7 @@ func GenerateDeploymentCommits(taskCtx plugin.SubTaskContext) errors.Error {
p.status,
p.duration_sec,
p.queued_duration_sec,
p.started_date,
p.created_date,
p.finished_date,
p.environment,
Expand Down Expand Up @@ -161,6 +163,7 @@ func GenerateDeploymentCommits(taskCtx plugin.SubTaskContext) errors.Error {
Environment: pipelineCommit.Environment,
TaskDatesInfo: devops.TaskDatesInfo{
CreatedDate: *pipelineCommit.CreatedDate,
StartedDate: pipelineCommit.StartedDate,
FinishedDate: pipelineCommit.FinishedDate,
},
DurationSec: pipelineCommit.DurationSec,
Expand All @@ -170,10 +173,13 @@ func GenerateDeploymentCommits(taskCtx plugin.SubTaskContext) errors.Error {
RepoId: pipelineCommit.RepoId,
RepoUrl: pipelineCommit.RepoUrl,
}
if pipelineCommit.FinishedDate != nil && pipelineCommit.DurationSec != nil {
s := pipelineCommit.FinishedDate.Add(-time.Duration(*pipelineCommit.DurationSec) * time.Second)
domainDeployCommit.StartedDate = &s
if domainDeployCommit.TaskDatesInfo.StartedDate == nil {
if pipelineCommit.FinishedDate != nil && pipelineCommit.DurationSec != nil {
s := pipelineCommit.FinishedDate.Add(-time.Duration(*pipelineCommit.DurationSec) * time.Second)
domainDeployCommit.StartedDate = &s
}
}

// it is tricky when Environment was declared on the cicd_tasks level
// lets talk common sense and assume that one pipeline can only be deployed to one environment
// so if the pipeline has both staging and production tasks, we will treat it as a production pipeline
Expand Down
Loading