You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ly...@apache.org on 2023/11/06 03:32:32 UTC
(incubator-devlake) branch main updated: update `status` and `result` fields' transformation in domain layer (#6398)
This is an automated email from the ASF dual-hosted git repository.
lynwee 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 67ed25f12 update `status` and `result` fields' transformation in domain layer (#6398)
67ed25f12 is described below
commit 67ed25f1298f449879008822d2490950613d5a30
Author: Lynwee <li...@merico.dev>
AuthorDate: Mon Nov 6 11:32:27 2023 +0800
update `status` and `result` fields' transformation in domain layer (#6398)
* refactor(framework): `devops.GetStatus` is case insensitive now
* refactor(db): update `result` and `status` fields' transformation rules
* fix(dora): fix e2e test
* fix(dora): update sql when generating deployment commits
* fix(db): remove `other` option for status tranformation rule
* fix(bamboo): fix e2e test
---
.../models/domainlayer/devops/cicd_pipeline.go | 76 ++++++++++------------
.../plugins/bamboo/tasks/deploy_build_convertor.go | 14 ++--
.../plugins/bamboo/tasks/job_build_convertor.go | 14 ++--
.../plugins/bamboo/tasks/plan_build_convertor.go | 14 ++--
backend/plugins/bamboo/tasks/shared.go | 23 +++++++
.../e2e/snapshot_tables/cicd_pipelines.csv | 20 +++---
.../bitbucket/e2e/snapshot_tables/cicd_tasks.csv | 32 ++++-----
backend/plugins/bitbucket/models/pipeline.go | 13 +++-
.../bitbucket/tasks/deployment_convertor.go | 13 ++--
.../plugins/bitbucket/tasks/pipeline_convertor.go | 16 ++---
.../bitbucket/tasks/pipeline_steps_convertor.go | 14 ++--
backend/plugins/circleci/tasks/job_converter.go | 12 ++--
.../plugins/circleci/tasks/workflow_converter.go | 12 ++--
.../cicd_deployment_commits.csv | 2 +-
.../e2e/deployment_generator/cicd_pipelines.csv | 2 +-
.../dora/tasks/deployment_commits_generator.go | 21 +++---
.../github/e2e/snapshot_tables/cicd_pipelines.csv | 4 +-
.../github/e2e/snapshot_tables/cicd_tasks.csv | 16 ++---
backend/plugins/github/tasks/cicd_job_convertor.go | 13 ++--
backend/plugins/github/tasks/cicd_run_convertor.go | 13 ++--
.../plugins/github/tasks/deployment_convertor.go | 19 ++----
backend/plugins/github/tasks/shared.go | 27 ++++++++
.../gitlab/e2e/snapshot_tables/cicd_tasks.csv | 4 +-
.../snapshot_tables/cicd_tasks_no_prod_regex.csv | 4 +-
.../plugins/gitlab/tasks/deployment_convertor.go | 18 ++---
backend/plugins/gitlab/tasks/job_convertor.go | 17 ++---
backend/plugins/gitlab/tasks/pipeline_convertor.go | 15 ++---
backend/plugins/gitlab/tasks/shared.go | 21 ++++++
.../snapshot_tables/cicd_tasks_after_stages.csv | 6 +-
.../plugins/jenkins/tasks/build_cicd_convertor.go | 11 ++--
backend/plugins/jenkins/tasks/shared.go | 9 +++
backend/plugins/jenkins/tasks/stage_convertor.go | 29 ++++-----
32 files changed, 295 insertions(+), 229 deletions(-)
diff --git a/backend/core/models/domainlayer/devops/cicd_pipeline.go b/backend/core/models/domainlayer/devops/cicd_pipeline.go
index aab64f985..6379c6a50 100644
--- a/backend/core/models/domainlayer/devops/cicd_pipeline.go
+++ b/backend/core/models/domainlayer/devops/cicd_pipeline.go
@@ -46,71 +46,73 @@ func (CICDPipeline) TableName() string {
const (
RESULT_SUCCESS = "SUCCESS"
RESULT_FAILURE = "FAILURE"
- RESULT_ABORT = "ABORT"
- RESULT_MANUAL = "MANUAL"
- RESULT_SKIPPED = "SKIPPED"
+ RESULT_DEFAULT = ""
)
// this is for the field `status` in table.cicd_pipelines and table.cicd_tasks
const (
- STATUS_NOT_STARTED = "NOT_STARTED"
STATUS_IN_PROGRESS = "IN_PROGRESS"
- STATUS_BLOCKED = "BLOCKED"
STATUS_DONE = "DONE"
+ STATUS_OTHER = "OTHER"
)
type ResultRule struct {
Success []string
- Failed []string
- Abort []string
- Manual []string
- Skipped []string
+ Failure []string
Default string
}
-type StatusRule[T comparable] struct {
- InProgress []T
- NotStarted []T
- Done []T
- Manual []T
+
+type StatusRule struct {
+ InProgress []string
+ Done []string
Default string
}
-func caseInSensitiveEqual(src string, dst string) bool {
- return strings.EqualFold(src, dst)
+type StatusRuleCommon[T comparable] struct {
+ InProgress []T
+ Done []T
+ Default string
}
-// GetResult compare the input with rule for return the enum value of result
+// GetResult compare the input with rule for return the enum value of result case-insensitively.
func GetResult(rule *ResultRule, input interface{}) string {
for _, suc := range rule.Success {
- if caseInSensitiveEqual(suc, cast.ToString(input)) {
+ if strings.EqualFold(suc, cast.ToString(input)) {
return RESULT_SUCCESS
}
}
- for _, fail := range rule.Failed {
- if caseInSensitiveEqual(fail, cast.ToString(input)) {
+ for _, fail := range rule.Failure {
+ if strings.EqualFold(fail, cast.ToString(input)) {
return RESULT_FAILURE
}
}
- for _, abort := range rule.Abort {
- if caseInSensitiveEqual(abort, cast.ToString(input)) {
- return RESULT_ABORT
- }
+ return rule.Default
+}
+
+// GetStatus compare the input with rule for return the enum value of status
+func GetStatus(rule *StatusRule, input string) string {
+ if rule.Default == "" {
+ rule.Default = STATUS_OTHER
}
- for _, manual := range rule.Manual {
- if caseInSensitiveEqual(manual, cast.ToString(input)) {
- return RESULT_MANUAL
+ for _, inProgress := range rule.InProgress {
+ if strings.EqualFold(inProgress, input) {
+ return STATUS_IN_PROGRESS
}
}
- for _, skipped := range rule.Skipped {
- if caseInSensitiveEqual(skipped, cast.ToString(input)) {
- return RESULT_SKIPPED
+ for _, done := range rule.Done {
+ if strings.EqualFold(done, input) {
+ return STATUS_DONE
}
}
return rule.Default
}
-// GetStatus compare the input with rule for return the enum value of status
-func GetStatus[T comparable](rule *StatusRule[T], input T) string {
+// GetStatusCommon compare the input with rule for return the enum value of status.
+// If T is string, it is case-sensitivity.
+func GetStatusCommon[T comparable](rule *StatusRuleCommon[T], input T) string {
+ if rule.Default == "" {
+ rule.Default = STATUS_OTHER
+ }
for _, inp := range rule.InProgress {
if inp == input {
return STATUS_IN_PROGRESS
@@ -121,15 +123,5 @@ func GetStatus[T comparable](rule *StatusRule[T], input T) string {
return STATUS_DONE
}
}
- for _, manual := range rule.Manual {
- if manual == input {
- return STATUS_BLOCKED
- }
- }
- for _, notStarted := range rule.NotStarted {
- if notStarted == input {
- return STATUS_NOT_STARTED
- }
- }
return rule.Default
}
diff --git a/backend/plugins/bamboo/tasks/deploy_build_convertor.go b/backend/plugins/bamboo/tasks/deploy_build_convertor.go
index 5b1bac142..885206137 100644
--- a/backend/plugins/bamboo/tasks/deploy_build_convertor.go
+++ b/backend/plugins/bamboo/tasks/deploy_build_convertor.go
@@ -113,14 +113,14 @@ func ConvertDeployBuilds(taskCtx plugin.SubTaskContext) errors.Error {
CicdDeploymentId: deploymentCommitId,
Name: input.GenerateCICDDeploymentCommitName(),
Result: devops.GetResult(&devops.ResultRule{
- Failed: []string{"Failed"},
- Success: []string{"Successful"},
- Default: input.DeploymentState,
+ Success: []string{ResultSuccess, ResultSuccessful},
+ Failure: []string{ResultFailed},
+ Default: devops.RESULT_DEFAULT,
}, input.DeploymentState),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- Done: []string{"Finished", "FINISHED"},
- NotStarted: []string{"not_built", "NOT_BUILT", "Not_Built", "PENDING", "QUEUED"},
- Default: devops.STATUS_IN_PROGRESS,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{StatusFinished},
+ InProgress: []string{StatusInProgress, StatusPending, StatusQueued},
+ Default: devops.STATUS_OTHER,
}, input.LifeCycleState),
Environment: input.Environment,
StartedDate: input.StartedDate,
diff --git a/backend/plugins/bamboo/tasks/job_build_convertor.go b/backend/plugins/bamboo/tasks/job_build_convertor.go
index 0d9d5c7f0..d170d177e 100644
--- a/backend/plugins/bamboo/tasks/job_build_convertor.go
+++ b/backend/plugins/bamboo/tasks/job_build_convertor.go
@@ -72,15 +72,15 @@ func ConvertJobBuilds(taskCtx plugin.SubTaskContext) errors.Error {
CicdScopeId: planIdGen.Generate(data.Options.ConnectionId, data.Options.PlanKey),
Result: devops.GetResult(&devops.ResultRule{
- Failed: []string{"Failed"},
- Success: []string{"Successful"},
- Default: line.BuildState,
+ Success: []string{ResultSuccess, ResultSuccessful},
+ Failure: []string{ResultFailed},
+ Default: devops.RESULT_DEFAULT,
}, line.BuildState),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- Done: []string{"Finished", "FINISHED"},
- NotStarted: []string{"not_built", "NOT_BUILT", "Not_Built", "PENDING", "QUEUED"},
- Default: devops.STATUS_IN_PROGRESS,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{StatusFinished},
+ InProgress: []string{StatusInProgress, StatusPending, StatusQueued},
+ Default: devops.STATUS_OTHER,
}, line.LifeCycleState),
}
diff --git a/backend/plugins/bamboo/tasks/plan_build_convertor.go b/backend/plugins/bamboo/tasks/plan_build_convertor.go
index 3f25dce68..ef235c87e 100644
--- a/backend/plugins/bamboo/tasks/plan_build_convertor.go
+++ b/backend/plugins/bamboo/tasks/plan_build_convertor.go
@@ -70,15 +70,15 @@ func ConvertPlanBuilds(taskCtx plugin.SubTaskContext) errors.Error {
CicdScopeId: planIdGen.Generate(data.Options.ConnectionId, data.Options.PlanKey),
Result: devops.GetResult(&devops.ResultRule{
- Failed: []string{"Failed"},
- Success: []string{"Successful"},
- Default: line.BuildState,
+ Success: []string{ResultSuccess, ResultSuccessful},
+ Failure: []string{ResultFailed},
+ Default: devops.RESULT_DEFAULT,
}, line.BuildState),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- Done: []string{"Finished", "FINISHED"},
- NotStarted: []string{"not_built", "NOT_BUILT", "Not_Built", "PENDING", "QUEUED"},
- Default: devops.STATUS_IN_PROGRESS,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{StatusFinished},
+ InProgress: []string{StatusInProgress, StatusPending, StatusQueued},
+ Default: devops.STATUS_OTHER,
}, line.LifeCycleState),
}
diff --git a/backend/plugins/bamboo/tasks/shared.go b/backend/plugins/bamboo/tasks/shared.go
index 0d834a0f0..d4d3a04e2 100644
--- a/backend/plugins/bamboo/tasks/shared.go
+++ b/backend/plugins/bamboo/tasks/shared.go
@@ -30,6 +30,29 @@ import (
"github.com/apache/incubator-devlake/plugins/bamboo/models"
)
+const (
+ // https://docs.atlassian.com/atlassian-bamboo/7.2.4/com/atlassian/bamboo/builder/BuildState.html
+ StatusFinished = "FINISHED"
+ StatusInProgress = "IN_PROGRESS"
+ StatusPending = "PENDING"
+ StatusQueued = "QUEUED"
+ StatusNotBuilt = "NOT_BUILT"
+
+ // https://docs.atlassian.com/atlassian-bamboo/7.2.4/com/atlassian/bamboo/builder/BuildState.html
+ // https://confluence.atlassian.com/bamkb/bamboo-deployment-status-776822787.html
+ ResultSuccess = "SUCCESS"
+ ResultFailed = "FAILED"
+ ResultUnknown = "UNKNOWN"
+ ResultReplaced = "REPLACED"
+ ResultSkipped = "SKIPPED"
+ ResultNever = "NEVER"
+ ResultQueued = "QUEUED"
+ ResultInProgress = "IN PROGRESS"
+ ResultNotBuilt = "NOT BUILT"
+
+ ResultSuccessful = "Successful"
+)
+
func CreateRawDataSubTaskArgs(taskCtx plugin.SubTaskContext, rawTable string) (*api.RawDataSubTaskArgs, *BambooTaskData) {
data := taskCtx.GetData().(*BambooTaskData)
filteredData := *data
diff --git a/backend/plugins/bitbucket/e2e/snapshot_tables/cicd_pipelines.csv b/backend/plugins/bitbucket/e2e/snapshot_tables/cicd_pipelines.csv
index a590150bf..dcf2852e6 100644
--- a/backend/plugins/bitbucket/e2e/snapshot_tables/cicd_pipelines.csv
+++ b/backend/plugins/bitbucket/e2e/snapshot_tables/cicd_pipelines.csv
@@ -1,11 +1,11 @@
id,name,result,status,type,duration_sec,environment
-bitbucket:BitbucketPipeline:1:{01fad871-cd21-4a80-bd59-74148dd5be8e},bitbucket:BitbucketPipeline:1:{01fad871-cd21-4a80-bd59-74148dd5be8e}/0,FAILURE,COMPLETED,DEPLOYMENT,14,
-bitbucket:BitbucketPipeline:1:{02c4dfe8-70a6-442c-8bd8-19061979c2cf},bitbucket:BitbucketPipeline:1:{02c4dfe8-70a6-442c-8bd8-19061979c2cf}/0,MANUAL,IN_PROGRESS,,0,
-bitbucket:BitbucketPipeline:1:{1e20072e-b22a-443f-ad92-3d9435393d5b},bitbucket:BitbucketPipeline:1:{1e20072e-b22a-443f-ad92-3d9435393d5b}/0,SUCCESS,COMPLETED,,21,
-bitbucket:BitbucketPipeline:1:{2d91d69f-d84b-423d-ae4d-c1d3f2c27166},bitbucket:BitbucketPipeline:1:{2d91d69f-d84b-423d-ae4d-c1d3f2c27166}/0,SUCCESS,COMPLETED,DEPLOYMENT,16,
-bitbucket:BitbucketPipeline:1:{5decbbb2-f4e6-4f3a-aab0-f74c40497c51},bitbucket:BitbucketPipeline:1:{5decbbb2-f4e6-4f3a-aab0-f74c40497c51}/0,SUCCESS,COMPLETED,,15,
-bitbucket:BitbucketPipeline:1:{5fb099c8-ebdd-4d3e-97d8-a12ebfca5446},bitbucket:BitbucketPipeline:1:{5fb099c8-ebdd-4d3e-97d8-a12ebfca5446}/0,MANUAL,IN_PROGRESS,,0,
-bitbucket:BitbucketPipeline:1:{8b417a17-72e6-4e16-ae4a-97f6e279f68e},bitbucket:BitbucketPipeline:1:{8b417a17-72e6-4e16-ae4a-97f6e279f68e}/0,MANUAL,IN_PROGRESS,,0,
-bitbucket:BitbucketPipeline:1:{b5d2ab02-2013-415e-b146-61ff3bf19502},bitbucket:BitbucketPipeline:1:{b5d2ab02-2013-415e-b146-61ff3bf19502}/0,ABORT,COMPLETED,,0,PRODUCTION
-bitbucket:BitbucketPipeline:1:{d7bf8394-6e18-42c4-b3a3-70514fc4079f},bitbucket:BitbucketPipeline:1:{d7bf8394-6e18-42c4-b3a3-70514fc4079f}/0,SUCCESS,COMPLETED,,18,PRODUCTION
-bitbucket:BitbucketPipeline:1:{ee91b6d3-7736-482c-892f-ad1e923d145e},bitbucket:BitbucketPipeline:1:{ee91b6d3-7736-482c-892f-ad1e923d145e}/0,FAILURE,COMPLETED,,0,
+bitbucket:BitbucketPipeline:1:{01fad871-cd21-4a80-bd59-74148dd5be8e},bitbucket:BitbucketPipeline:1:{01fad871-cd21-4a80-bd59-74148dd5be8e}/0,FAILURE,DONE,DEPLOYMENT,14,
+bitbucket:BitbucketPipeline:1:{02c4dfe8-70a6-442c-8bd8-19061979c2cf},bitbucket:BitbucketPipeline:1:{02c4dfe8-70a6-442c-8bd8-19061979c2cf}/0,,IN_PROGRESS,,0,
+bitbucket:BitbucketPipeline:1:{1e20072e-b22a-443f-ad92-3d9435393d5b},bitbucket:BitbucketPipeline:1:{1e20072e-b22a-443f-ad92-3d9435393d5b}/0,SUCCESS,DONE,,21,
+bitbucket:BitbucketPipeline:1:{2d91d69f-d84b-423d-ae4d-c1d3f2c27166},bitbucket:BitbucketPipeline:1:{2d91d69f-d84b-423d-ae4d-c1d3f2c27166}/0,SUCCESS,DONE,DEPLOYMENT,16,
+bitbucket:BitbucketPipeline:1:{5decbbb2-f4e6-4f3a-aab0-f74c40497c51},bitbucket:BitbucketPipeline:1:{5decbbb2-f4e6-4f3a-aab0-f74c40497c51}/0,SUCCESS,DONE,,15,
+bitbucket:BitbucketPipeline:1:{5fb099c8-ebdd-4d3e-97d8-a12ebfca5446},bitbucket:BitbucketPipeline:1:{5fb099c8-ebdd-4d3e-97d8-a12ebfca5446}/0,,IN_PROGRESS,,0,
+bitbucket:BitbucketPipeline:1:{8b417a17-72e6-4e16-ae4a-97f6e279f68e},bitbucket:BitbucketPipeline:1:{8b417a17-72e6-4e16-ae4a-97f6e279f68e}/0,,IN_PROGRESS,,0,
+bitbucket:BitbucketPipeline:1:{b5d2ab02-2013-415e-b146-61ff3bf19502},bitbucket:BitbucketPipeline:1:{b5d2ab02-2013-415e-b146-61ff3bf19502}/0,FAILURE,DONE,,0,PRODUCTION
+bitbucket:BitbucketPipeline:1:{d7bf8394-6e18-42c4-b3a3-70514fc4079f},bitbucket:BitbucketPipeline:1:{d7bf8394-6e18-42c4-b3a3-70514fc4079f}/0,SUCCESS,DONE,,18,PRODUCTION
+bitbucket:BitbucketPipeline:1:{ee91b6d3-7736-482c-892f-ad1e923d145e},bitbucket:BitbucketPipeline:1:{ee91b6d3-7736-482c-892f-ad1e923d145e}/0,FAILURE,DONE,,0,
diff --git a/backend/plugins/bitbucket/e2e/snapshot_tables/cicd_tasks.csv b/backend/plugins/bitbucket/e2e/snapshot_tables/cicd_tasks.csv
index 48f1897a1..c60d2d387 100644
--- a/backend/plugins/bitbucket/e2e/snapshot_tables/cicd_tasks.csv
+++ b/backend/plugins/bitbucket/e2e/snapshot_tables/cicd_tasks.csv
@@ -1,17 +1,17 @@
id,name,pipeline_id,result,status,type,duration_sec,started_date,finished_date,environment,cicd_scope_id,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
-bitbucket:BitbucketPipelineStep:1:{009577b4-99a8-4498-99bf-a00ef7254ca3},staging,bitbucket:BitbucketPipeline:1:{5decbbb2-f4e6-4f3a-aab0-f74c40497c51},SUCCESS,COMPLETED,,0,2023-02-20T09:38:47.203+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,285,
-bitbucket:BitbucketPipelineStep:1:{0706054d-bde3-4d27-af26-8ff9bc675e6c},production,bitbucket:BitbucketPipeline:1:{5decbbb2-f4e6-4f3a-aab0-f74c40497c51},SUCCESS,COMPLETED,,0,2023-02-20T09:39:04.211+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,286,
-bitbucket:BitbucketPipelineStep:1:{0fa0137f-e029-459e-8760-289ed9e6b57d},Test,bitbucket:BitbucketPipeline:1:{5decbbb2-f4e6-4f3a-aab0-f74c40497c51},SUCCESS,COMPLETED,,0,2023-02-20T09:38:30.581+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,284,
-bitbucket:BitbucketPipelineStep:1:{1218e6e3-f34e-4ebc-a767-2a69285681ca},staging,bitbucket:BitbucketPipeline:1:{2d91d69f-d84b-423d-ae4d-c1d3f2c27166},SUCCESS,COMPLETED,,0,2023-02-20T09:23:50.415+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,144,
-bitbucket:BitbucketPipelineStep:1:{148bfd03-8b7f-4483-982c-18b020124350},production,bitbucket:BitbucketPipeline:1:{b5d2ab02-2013-415e-b146-61ff3bf19502},,COMPLETED,,0,2023-02-20T09:23:40.970+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,533,
-bitbucket:BitbucketPipelineStep:1:{263500ac-4242-4996-95bd-739b5cafd3ef},Test,bitbucket:BitbucketPipeline:1:{1e20072e-b22a-443f-ad92-3d9435393d5b},SUCCESS,COMPLETED,,0,2023-02-20T09:12:34.572+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,91,
-bitbucket:BitbucketPipelineStep:1:{2915edc8-9a5a-4a76-831b-f7ce30938d4e},staging,bitbucket:BitbucketPipeline:1:{b5d2ab02-2013-415e-b146-61ff3bf19502},,COMPLETED,,0,2023-02-20T09:23:40.928+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,532,
-bitbucket:BitbucketPipelineStep:1:{61e34fbf-87a2-4271-827e-b336ff4c4396},staging,bitbucket:BitbucketPipeline:1:{d7bf8394-6e18-42c4-b3a3-70514fc4079f},SUCCESS,COMPLETED,,0,2023-02-20T09:15:45.450+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,632,
-bitbucket:BitbucketPipelineStep:1:{74ceee44-533a-489b-8d9b-3c9c0ef57ff3},production,bitbucket:BitbucketPipeline:1:{2d91d69f-d84b-423d-ae4d-c1d3f2c27166},SUCCESS,COMPLETED,,0,2023-02-20T09:24:05.997+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,145,
-bitbucket:BitbucketPipelineStep:1:{9b079475-6fed-40bb-b591-711351c12f71},Test,bitbucket:BitbucketPipeline:1:{2d91d69f-d84b-423d-ae4d-c1d3f2c27166},SUCCESS,COMPLETED,,0,2023-02-20T09:23:31.978+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,143,
-bitbucket:BitbucketPipelineStep:1:{a72dea81-cd04-45db-8af9-958ed814d050},Test,bitbucket:BitbucketPipeline:1:{1e20072e-b22a-443f-ad92-3d9435393d5b},SUCCESS,COMPLETED,,0,2023-02-20T09:12:04.411+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,90,
-bitbucket:BitbucketPipelineStep:1:{ac0a2d0b-d67d-47c6-8e23-ee33ccdfe2d8},Test,bitbucket:BitbucketPipeline:1:{b5d2ab02-2013-415e-b146-61ff3bf19502},ABORT,COMPLETED,,0,2023-02-20T09:23:40.750+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,531,
-bitbucket:BitbucketPipelineStep:1:{c2da4b2d-f971-4c5f-90b7-1c55ea80121c},production,bitbucket:BitbucketPipeline:1:{d7bf8394-6e18-42c4-b3a3-70514fc4079f},SUCCESS,COMPLETED,,0,2023-02-20T09:16:01.886+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,633,
-bitbucket:BitbucketPipelineStep:1:{caf86c6c-c60a-4e62-b838-6480ad110182},Test,bitbucket:BitbucketPipeline:1:{1e20072e-b22a-443f-ad92-3d9435393d5b},SUCCESS,COMPLETED,,0,2023-02-20T09:11:43.393+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,89,
-bitbucket:BitbucketPipelineStep:1:{d464ab91-8b50-4ad5-8c22-d2a6d1ca5d22},Test,bitbucket:BitbucketPipeline:1:{01fad871-cd21-4a80-bd59-74148dd5be8e},FAILURE,COMPLETED,,0,2023-02-20T08:58:31.520+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,1,
-bitbucket:BitbucketPipelineStep:1:{e4753fd7-469e-4d15-a689-0fd882fee2d4},Test,bitbucket:BitbucketPipeline:1:{d7bf8394-6e18-42c4-b3a3-70514fc4079f},SUCCESS,COMPLETED,,0,2023-02-20T09:17:33.116+00:00,,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,631,
+bitbucket:BitbucketPipelineStep:1:{009577b4-99a8-4498-99bf-a00ef7254ca3},staging,bitbucket:BitbucketPipeline:1:{5decbbb2-f4e6-4f3a-aab0-f74c40497c51},SUCCESS,DONE,,5,2023-02-20T09:38:47.203+00:00,2023-02-20T09:38:52.307+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,285,
+bitbucket:BitbucketPipelineStep:1:{0706054d-bde3-4d27-af26-8ff9bc675e6c},production,bitbucket:BitbucketPipeline:1:{5decbbb2-f4e6-4f3a-aab0-f74c40497c51},SUCCESS,DONE,,5,2023-02-20T09:39:04.211+00:00,2023-02-20T09:39:09.267+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,286,
+bitbucket:BitbucketPipelineStep:1:{0fa0137f-e029-459e-8760-289ed9e6b57d},Test,bitbucket:BitbucketPipeline:1:{5decbbb2-f4e6-4f3a-aab0-f74c40497c51},SUCCESS,DONE,,4,2023-02-20T09:38:30.581+00:00,2023-02-20T09:38:35.012+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,284,
+bitbucket:BitbucketPipelineStep:1:{1218e6e3-f34e-4ebc-a767-2a69285681ca},staging,bitbucket:BitbucketPipeline:1:{2d91d69f-d84b-423d-ae4d-c1d3f2c27166},SUCCESS,DONE,,5,2023-02-20T09:23:50.415+00:00,2023-02-20T09:23:55.180+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,144,
+bitbucket:BitbucketPipelineStep:1:{148bfd03-8b7f-4483-982c-18b020124350},production,bitbucket:BitbucketPipeline:1:{b5d2ab02-2013-415e-b146-61ff3bf19502},,DONE,,0,2023-02-20T09:23:40.970+00:00,2023-02-20T09:23:40.970+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,533,
+bitbucket:BitbucketPipelineStep:1:{263500ac-4242-4996-95bd-739b5cafd3ef},Test,bitbucket:BitbucketPipeline:1:{1e20072e-b22a-443f-ad92-3d9435393d5b},SUCCESS,DONE,,5,2023-02-20T09:12:34.572+00:00,2023-02-20T09:12:39.614+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,91,
+bitbucket:BitbucketPipelineStep:1:{2915edc8-9a5a-4a76-831b-f7ce30938d4e},staging,bitbucket:BitbucketPipeline:1:{b5d2ab02-2013-415e-b146-61ff3bf19502},,DONE,,0,2023-02-20T09:23:40.928+00:00,2023-02-20T09:23:40.928+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,532,
+bitbucket:BitbucketPipelineStep:1:{61e34fbf-87a2-4271-827e-b336ff4c4396},staging,bitbucket:BitbucketPipeline:1:{d7bf8394-6e18-42c4-b3a3-70514fc4079f},SUCCESS,DONE,,5,2023-02-20T09:15:45.450+00:00,2023-02-20T09:15:50.609+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,632,
+bitbucket:BitbucketPipelineStep:1:{74ceee44-533a-489b-8d9b-3c9c0ef57ff3},production,bitbucket:BitbucketPipeline:1:{2d91d69f-d84b-423d-ae4d-c1d3f2c27166},SUCCESS,DONE,,6,2023-02-20T09:24:05.997+00:00,2023-02-20T09:24:12.269+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,145,
+bitbucket:BitbucketPipelineStep:1:{9b079475-6fed-40bb-b591-711351c12f71},Test,bitbucket:BitbucketPipeline:1:{2d91d69f-d84b-423d-ae4d-c1d3f2c27166},SUCCESS,DONE,,5,2023-02-20T09:23:31.978+00:00,2023-02-20T09:23:36.923+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,143,
+bitbucket:BitbucketPipelineStep:1:{a72dea81-cd04-45db-8af9-958ed814d050},Test,bitbucket:BitbucketPipeline:1:{1e20072e-b22a-443f-ad92-3d9435393d5b},SUCCESS,DONE,,6,2023-02-20T09:12:04.411+00:00,2023-02-20T09:12:10.347+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,90,
+bitbucket:BitbucketPipelineStep:1:{ac0a2d0b-d67d-47c6-8e23-ee33ccdfe2d8},Test,bitbucket:BitbucketPipeline:1:{b5d2ab02-2013-415e-b146-61ff3bf19502},FAILURE,DONE,,0,2023-02-20T09:23:40.750+00:00,2023-02-20T09:23:40.750+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,531,
+bitbucket:BitbucketPipelineStep:1:{c2da4b2d-f971-4c5f-90b7-1c55ea80121c},production,bitbucket:BitbucketPipeline:1:{d7bf8394-6e18-42c4-b3a3-70514fc4079f},SUCCESS,DONE,,8,2023-02-20T09:16:01.886+00:00,2023-02-20T09:16:09.885+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,633,
+bitbucket:BitbucketPipelineStep:1:{caf86c6c-c60a-4e62-b838-6480ad110182},Test,bitbucket:BitbucketPipeline:1:{1e20072e-b22a-443f-ad92-3d9435393d5b},SUCCESS,DONE,,10,2023-02-20T09:11:43.393+00:00,2023-02-20T09:11:53.145+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,89,
+bitbucket:BitbucketPipelineStep:1:{d464ab91-8b50-4ad5-8c22-d2a6d1ca5d22},Test,bitbucket:BitbucketPipeline:1:{01fad871-cd21-4a80-bd59-74148dd5be8e},FAILURE,DONE,,14,2023-02-20T08:58:31.520+00:00,2023-02-20T08:58:45.945+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,1,
+bitbucket:BitbucketPipelineStep:1:{e4753fd7-469e-4d15-a689-0fd882fee2d4},Test,bitbucket:BitbucketPipeline:1:{d7bf8394-6e18-42c4-b3a3-70514fc4079f},SUCCESS,DONE,,5,2023-02-20T09:17:33.116+00:00,2023-02-20T09:17:37.835+00:00,,bitbucket:BitbucketRepo:1:likyh/likyhphp,"{""ConnectionId"":1,""FullName"":""likyh/likyhphp""}",_raw_bitbucket_api_pipeline_steps,631,
diff --git a/backend/plugins/bitbucket/models/pipeline.go b/backend/plugins/bitbucket/models/pipeline.go
index fbd4a25bb..57e40e3d8 100644
--- a/backend/plugins/bitbucket/models/pipeline.go
+++ b/backend/plugins/bitbucket/models/pipeline.go
@@ -48,6 +48,11 @@ func (BitbucketPipeline) TableName() string {
}
const (
+ // https://github.com/juan-carlos-duarte/bitbucket-api-client-lib/blob/main/docs/PipelineState.md
+ // https://community.atlassian.com/t5/Bitbucket-questions/Possible-value-for-status-filtering-in-API-pipelines/qaq-p/1755200
+ // https://github.com/juan-carlos-duarte/bitbucket-api-client-lib/blob/main/docs/PipelineState.md
+ // https://developer.atlassian.com/server/bitbucket/rest/v815/api-group-builds-and-deployments/#api-api-latest-projects-projectkey-repos-repositoryslug-commits-commitid-deployments-get
+ // https://github.com/juan-carlos-duarte/bitbucket-api-client-lib/blob/main/docs/DeploymentStateCompleted.md
FAILED = "FAILED"
ERROR = "ERROR"
UNDEPLOYED = "UNDEPLOYED"
@@ -55,9 +60,15 @@ const (
SKIPPED = "SKIPPED"
SUCCESSFUL = "SUCCESSFUL"
COMPLETED = "COMPLETED"
- PAUSED = "COMPLETED"
+ PAUSED = "PAUSED"
HALTED = "HALTED"
IN_PROGRESS = "IN_PROGRESS"
PENDING = "PENDING"
BUILDING = "BUILDING"
+ EXPIRED = "EXPIRED"
+ RUNNING = "RUNNING"
+ READY = "READY"
+ PASSED = "PASSED"
+ NOT_RUN = "NOT_RUN"
+ CANCELLED = "CANCELLED"
)
diff --git a/backend/plugins/bitbucket/tasks/deployment_convertor.go b/backend/plugins/bitbucket/tasks/deployment_convertor.go
index e4aeb95f4..43f69e277 100644
--- a/backend/plugins/bitbucket/tasks/deployment_convertor.go
+++ b/backend/plugins/bitbucket/tasks/deployment_convertor.go
@@ -87,13 +87,14 @@ func ConvertDeployments(taskCtx plugin.SubTaskContext) errors.Error {
CicdScopeId: repoId,
Name: bitbucketDeployment.Name,
Result: devops.GetResult(&devops.ResultRule{
- Failed: []string{},
- Success: []string{models.COMPLETED},
- Default: "",
+ Success: []string{models.COMPLETED, models.SUCCESSFUL},
+ Failure: []string{models.FAILED, models.STOPPED, models.CANCELLED},
+ Default: devops.RESULT_DEFAULT,
}, bitbucketDeployment.Status),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- Done: []string{models.COMPLETED},
- Default: bitbucketDeployment.Status,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{models.COMPLETED, models.SUCCESSFUL, models.FAILED, models.STOPPED},
+ InProgress: []string{models.IN_PROGRESS},
+ Default: devops.STATUS_OTHER,
}, bitbucketDeployment.Status),
Environment: strings.ToUpper(bitbucketDeployment.Environment), // or bitbucketDeployment.EnvironmentType, they are same so far.
CreatedDate: *bitbucketDeployment.CreatedOn,
diff --git a/backend/plugins/bitbucket/tasks/pipeline_convertor.go b/backend/plugins/bitbucket/tasks/pipeline_convertor.go
index 860c9ca6c..219599f09 100644
--- a/backend/plugins/bitbucket/tasks/pipeline_convertor.go
+++ b/backend/plugins/bitbucket/tasks/pipeline_convertor.go
@@ -88,16 +88,14 @@ func ConvertPipelines(taskCtx plugin.SubTaskContext) errors.Error {
},
Name: fmt.Sprintf("%s/%d", domainEntityId, bitbucketPipeline.BuildNumber),
Result: devops.GetResult(&devops.ResultRule{
- Failed: []string{models.FAILED, models.ERROR},
- Abort: []string{models.STOPPED},
- Success: []string{models.SUCCESSFUL, models.COMPLETED},
- Manual: []string{models.PAUSED, models.HALTED},
- Skipped: []string{models.SKIPPED},
- Default: "",
+ Success: []string{models.SUCCESSFUL, models.COMPLETED, models.PASSED},
+ Failure: []string{models.FAILED, models.ERROR, models.STOPPED, models.ERROR},
+ Default: devops.RESULT_DEFAULT,
}, bitbucketPipeline.Result),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- InProgress: []string{models.IN_PROGRESS, models.PENDING, models.BUILDING},
- Default: bitbucketPipeline.Status,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{models.COMPLETED, models.SUCCESSFUL, models.PASSED, models.FAILED, models.ERROR, models.STOPPED, models.HALTED},
+ InProgress: []string{models.IN_PROGRESS, models.PENDING, models.RUNNING, models.PAUSED, models.BUILDING},
+ Default: devops.STATUS_OTHER,
}, bitbucketPipeline.Status),
Type: bitbucketPipeline.Type,
Environment: bitbucketPipeline.Environment,
diff --git a/backend/plugins/bitbucket/tasks/pipeline_steps_convertor.go b/backend/plugins/bitbucket/tasks/pipeline_steps_convertor.go
index 29eeba89d..55baa8196 100644
--- a/backend/plugins/bitbucket/tasks/pipeline_steps_convertor.go
+++ b/backend/plugins/bitbucket/tasks/pipeline_steps_convertor.go
@@ -69,16 +69,14 @@ func ConvertPipelineSteps(taskCtx plugin.SubTaskContext) errors.Error {
Name: bitbucketPipelineStep.Name,
PipelineId: pipelineIdGen.Generate(data.Options.ConnectionId, bitbucketPipelineStep.PipelineId),
Result: devops.GetResult(&devops.ResultRule{
- Failed: []string{models.FAILED, models.ERROR},
- Abort: []string{models.STOPPED},
Success: []string{models.SUCCESSFUL, models.COMPLETED},
- Manual: []string{models.PAUSED, models.HALTED},
- Skipped: []string{models.SKIPPED},
- Default: "",
+ Failure: []string{models.FAILED, models.ERROR, models.STOPPED},
+ Default: devops.RESULT_DEFAULT,
}, bitbucketPipelineStep.Result),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- InProgress: []string{models.IN_PROGRESS, models.PENDING, models.BUILDING},
- Default: bitbucketPipelineStep.State,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{models.COMPLETED, models.SUCCESSFUL, models.FAILED, models.ERROR, models.STOPPED},
+ InProgress: []string{models.IN_PROGRESS, models.PENDING, models.BUILDING, models.READY},
+ Default: devops.STATUS_OTHER,
}, bitbucketPipelineStep.State),
CicdScopeId: repoIdGen.Generate(data.Options.ConnectionId, data.Options.FullName),
}
diff --git a/backend/plugins/circleci/tasks/job_converter.go b/backend/plugins/circleci/tasks/job_converter.go
index f2abdf67e..9fbfc40f1 100644
--- a/backend/plugins/circleci/tasks/job_converter.go
+++ b/backend/plugins/circleci/tasks/job_converter.go
@@ -67,16 +67,14 @@ func ConvertJobs(taskCtx plugin.SubTaskContext) errors.Error {
FinishedDate: userTool.StoppedAt.ToNullableTime(),
DurationSec: userTool.DurationSec,
// reference: https://circleci.com/docs/api/v2/index.html#operation/getJobDetails
- Status: devops.GetStatus(&devops.StatusRule[string]{
- Done: []string{"canceled", "failed", "failing", "success", "not_run", "error", "infrastructure_fail", "timedout", "terminated-unknown"},
- Manual: []string{"on_hold", "blocked"},
- Default: devops.STATUS_IN_PROGRESS,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{"canceled", "failed", "failing", "success", "not_run", "error", "infrastructure_fail", "timedout", "terminated-unknown"}, // on_hold,blocked
+ Default: devops.STATUS_OTHER,
}, userTool.Status),
Result: devops.GetResult(&devops.ResultRule{
Success: []string{"success"},
- Failed: []string{"failed", "failing", "error"},
- Skipped: []string{"not_run"},
- Abort: []string{"canceled"},
+ Failure: []string{"failed", "failing", "error"}, // not_run,canceled
+ Default: devops.RESULT_DEFAULT,
}, userTool.Status),
Type: data.RegexEnricher.ReturnNameIfMatched(devops.DEPLOYMENT, userTool.Name),
Environment: data.RegexEnricher.ReturnNameIfOmittedOrMatched(devops.PRODUCTION, userTool.Name),
diff --git a/backend/plugins/circleci/tasks/workflow_converter.go b/backend/plugins/circleci/tasks/workflow_converter.go
index 741c19c11..b7c6c2eca 100644
--- a/backend/plugins/circleci/tasks/workflow_converter.go
+++ b/backend/plugins/circleci/tasks/workflow_converter.go
@@ -66,16 +66,14 @@ func ConvertWorkflows(taskCtx plugin.SubTaskContext) errors.Error {
FinishedDate: userTool.StoppedAt.ToNullableTime(),
CicdScopeId: getProjectIdGen().Generate(data.Options.ConnectionId, userTool.ProjectSlug),
// reference: https://circleci.com/docs/api/v2/index.html#operation/getWorkflowById
- Status: devops.GetStatus(&devops.StatusRule[string]{
- Done: []string{"canceled", "failed", "failing", "success", "not_run", "error"},
- Manual: []string{"on_hold"},
- Default: devops.STATUS_IN_PROGRESS,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{"canceled", "failed", "failing", "success", "not_run", "error"}, // on_hold
+ Default: devops.STATUS_OTHER,
}, userTool.Status),
Result: devops.GetResult(&devops.ResultRule{
Success: []string{"success"},
- Failed: []string{"failed", "failing", "error"},
- Skipped: []string{"not_run"},
- Abort: []string{"canceled"},
+ Failure: []string{"failed", "failing", "error"}, // not_run,canceled
+ Default: devops.RESULT_DEFAULT,
}, userTool.Status),
Type: data.RegexEnricher.ReturnNameIfMatched(devops.DEPLOYMENT, userTool.Name),
Environment: data.RegexEnricher.ReturnNameIfOmittedOrMatched(devops.PRODUCTION, userTool.Name),
diff --git a/backend/plugins/dora/e2e/deployment_generator/cicd_deployment_commits.csv b/backend/plugins/dora/e2e/deployment_generator/cicd_deployment_commits.csv
index 980576383..473e25b40 100644
--- a/backend/plugins/dora/e2e/deployment_generator/cicd_deployment_commits.csv
+++ b/backend/plugins/dora/e2e/deployment_generator/cicd_deployment_commits.csv
@@ -1,5 +1,5 @@
id,commit_sha,cicd_scope_id,cicd_deployment_id,result,repo_url,environment,started_date,finished_date
-gitlab:GitlabPipeline:1:457475337:https://gitlab.com/gitlab-data/snowflake_spend,10a6464b6bd2cf4b59b8ac37ce1466e013f5a20d,cicd1,gitlab:GitlabPipeline:1:457475337,ABORTED,https://gitlab.com/gitlab-data/snowflake_spend,PRODUCTION,,
+gitlab:GitlabPipeline:1:457475337:https://gitlab.com/gitlab-data/snowflake_spend,10a6464b6bd2cf4b59b8ac37ce1466e013f5a20d,cicd1,gitlab:GitlabPipeline:1:457475337,FAILURE,https://gitlab.com/gitlab-data/snowflake_spend,PRODUCTION,,
gitlab:GitlabPipeline:1:485811050:https://gitlab.com/gitlab-data/snowflake_spend,c791ea6949d6b4aadf79b15ba666cb690c6527ac,cicd1,gitlab:GitlabPipeline:1:485811050,FAILURE,https://gitlab.com/gitlab-data/snowflake_spend,PRODUCTION,2022-03-07T06:26:42.109+00:00,2022-03-07T06:26:42.109+00:00
gitlab:GitlabPipeline:1:485813816:https://gitlab.com/gitlab-data/snowflake_spend,ecc7c0b2874c812ed882c9effbbda26e0abc7110,cicd1,gitlab:GitlabPipeline:1:485813816,FAILURE,https://gitlab.com/gitlab-data/snowflake_spend,PRODUCTION,2022-03-07T06:33:56.824+00:00,2022-03-07T06:33:56.824+00:00
gitlab:GitlabPipeline:1:485814501:https://gitlab.com/gitlab-data/snowflake_spend,6a3346f8434cc65fbe3f7a80a0edec5b4014a733,cicd1,gitlab:GitlabPipeline:1:485814501,FAILURE,https://gitlab.com/gitlab-data/snowflake_spend,PRODUCTION,2022-03-07T06:35:28.111+00:00,2022-03-07T06:35:28.111+00:00
diff --git a/backend/plugins/dora/e2e/deployment_generator/cicd_pipelines.csv b/backend/plugins/dora/e2e/deployment_generator/cicd_pipelines.csv
index aa57b288d..cd5e6c2af 100644
--- a/backend/plugins/dora/e2e/deployment_generator/cicd_pipelines.csv
+++ b/backend/plugins/dora/e2e/deployment_generator/cicd_pipelines.csv
@@ -1,6 +1,6 @@
id,name,result,status,type,duration_sec,environment,created_date,finished_date,cicd_scope_id
gitlab:GitlabPipeline:1:457475160,cicd1,FAILURE,DONE,,0,,2022-01-27T10:07:26.435+00:00,2022-01-27T10:07:26.638+00:00,cicd1
-gitlab:GitlabPipeline:1:457475337,cicd1,ABORTED,IN_PROGRESS,,0,,2022-01-27T10:07:36.502+00:00,,cicd1
+gitlab:GitlabPipeline:1:457475337,cicd1,FAILURE,IN_PROGRESS,,0,,2022-01-27T10:07:36.502+00:00,,cicd1
gitlab:GitlabPipeline:1:485811050,cicd1,FAILURE,DONE,DEPLOYMENT,0,PRODUCTION,2022-03-07T06:26:42.109+00:00,2022-03-07T06:26:42.109+00:00,cicd1
gitlab:GitlabPipeline:1:485811059,cicd1,FAILURE,DONE,,0,,2022-03-07T06:26:43.784+00:00,2022-03-07T06:26:43.784+00:00,cicd1
gitlab:GitlabPipeline:1:485813816,cicd1,FAILURE,DONE,DEPLOYMENT,0,PRODUCTION,2022-03-07T06:33:56.824+00:00,2022-03-07T06:33:56.824+00:00,cicd1
diff --git a/backend/plugins/dora/tasks/deployment_commits_generator.go b/backend/plugins/dora/tasks/deployment_commits_generator.go
index eb15365da..34237e141 100644
--- a/backend/plugins/dora/tasks/deployment_commits_generator.go
+++ b/backend/plugins/dora/tasks/deployment_commits_generator.go
@@ -58,6 +58,7 @@ func GenerateDeploymentCommits(taskCtx plugin.SubTaskContext) errors.Error {
data := taskCtx.GetData().(*DoraTaskData)
// select all cicd_pipeline_commits from all "Deployments" in the project
// Note that failed records shall be included as well
+ noneSkippedResult := []string{devops.RESULT_FAILURE, devops.RESULT_SUCCESS}
cursor, err := db.Cursor(
dal.Select(
`
@@ -69,16 +70,16 @@ func GenerateDeploymentCommits(taskCtx plugin.SubTaskContext) errors.Error {
p.finished_date,
p.environment,
p.cicd_scope_id,
- EXISTS(SELECT 1 FROM cicd_tasks t WHERE t.pipeline_id = p.id AND t.environment = ? AND t.result <> ?)
+ EXISTS(SELECT 1 FROM cicd_tasks t WHERE t.pipeline_id = p.id AND t.environment = ? AND t.result IN ?)
as has_testing_tasks,
- EXISTS(SELECT 1 FROM cicd_tasks t WHERE t.pipeline_id = p.id AND t.environment = ? AND t.result <> ?)
+ EXISTS(SELECT 1 FROM cicd_tasks t WHERE t.pipeline_id = p.id AND t.environment = ? AND t.result IN ?)
as has_staging_tasks,
- EXISTS( SELECT 1 FROM cicd_tasks t WHERE t.pipeline_id = p.id AND t.environment = ? AND t.result <> ?)
+ EXISTS( SELECT 1 FROM cicd_tasks t WHERE t.pipeline_id = p.id AND t.environment = ? AND t.result IN ?)
as has_production_tasks
`,
- devops.TESTING, devops.RESULT_SKIPPED,
- devops.STAGING, devops.RESULT_SKIPPED,
- devops.PRODUCTION, devops.RESULT_SKIPPED,
+ devops.TESTING, noneSkippedResult,
+ devops.STAGING, noneSkippedResult,
+ devops.PRODUCTION, noneSkippedResult,
),
dal.From("cicd_pipeline_commits pc"),
dal.Join("LEFT JOIN cicd_pipelines p ON (p.id = pc.pipeline_id)"),
@@ -87,15 +88,15 @@ func GenerateDeploymentCommits(taskCtx plugin.SubTaskContext) errors.Error {
`
pm.project_name = ? AND (
p.type = ? OR EXISTS(
- SELECT 1 FROM cicd_tasks t WHERE t.pipeline_id = p.id AND t.type = ? AND t.result <> ?
+ SELECT 1 FROM cicd_tasks t WHERE t.pipeline_id = p.id AND t.type = ? AND t.result IN ?
)
- ) AND p.result <> ?
+ ) AND p.result IN ?
`,
data.Options.ProjectName,
devops.DEPLOYMENT,
devops.DEPLOYMENT,
- devops.RESULT_SKIPPED,
- devops.RESULT_SKIPPED,
+ noneSkippedResult,
+ noneSkippedResult,
),
)
if err != nil {
diff --git a/backend/plugins/github/e2e/snapshot_tables/cicd_pipelines.csv b/backend/plugins/github/e2e/snapshot_tables/cicd_pipelines.csv
index 652a0f98d..5e52c31fd 100644
--- a/backend/plugins/github/e2e/snapshot_tables/cicd_pipelines.csv
+++ b/backend/plugins/github/e2e/snapshot_tables/cicd_pipelines.csv
@@ -2,8 +2,8 @@ id,name,result,status,type,duration_sec,environment,created_date,finished_date,c
github:GithubRun:1:134018330:2559400712,CodeQL,SUCCESS,DONE,DEPLOYMENT,116353,PRODUCTION,2022-06-25T04:17:45.000+00:00,2022-06-26T12:36:58.000+00:00,github:GithubRepo:1:134018330
github:GithubRun:1:134018330:2559400713,Lint,SUCCESS,DONE,,116317,PRODUCTION,2022-06-25T04:17:45.000+00:00,2022-06-26T12:36:22.000+00:00,github:GithubRepo:1:134018330
github:GithubRun:1:134018330:2559400714,Tests,SUCCESS,DONE,,116619,,2022-06-25T04:17:45.000+00:00,2022-06-26T12:41:24.000+00:00,github:GithubRepo:1:134018330
-github:GithubRun:1:134018330:2559507315,CodeQL,,IN_PROGRESS,DEPLOYMENT,0,PRODUCTION,2022-06-25T05:02:56.000+00:00,2022-06-25T05:03:53.000+00:00,github:GithubRepo:1:134018330
-github:GithubRun:1:134018330:2566218975,Tests,,IN_PROGRESS,,0,,2022-06-27T01:29:54.000+00:00,2022-06-27T01:37:33.000+00:00,github:GithubRepo:1:134018330
+github:GithubRun:1:134018330:2559507315,CodeQL,,OTHER,DEPLOYMENT,0,PRODUCTION,2022-06-25T05:02:56.000+00:00,2022-06-25T05:03:53.000+00:00,github:GithubRepo:1:134018330
+github:GithubRun:1:134018330:2566218975,Tests,,OTHER,,0,,2022-06-27T01:29:54.000+00:00,2022-06-27T01:37:33.000+00:00,github:GithubRepo:1:134018330
github:GithubRun:1:134018330:2566218976,CodeQL,SUCCESS,DONE,DEPLOYMENT,61,PRODUCTION,2022-06-27T01:29:54.000+00:00,2022-06-27T01:30:55.000+00:00,github:GithubRepo:1:134018330
github:GithubRun:1:134018330:2566218977,Lint,FAILURE,DONE,,34,,2022-06-27T01:29:54.000+00:00,2022-06-27T01:30:28.000+00:00,github:GithubRepo:1:134018330
github:GithubRun:1:134018330:2589885628,Tests,SUCCESS,DONE,,91030,,2022-06-30T12:23:37.000+00:00,2022-07-01T13:40:47.000+00:00,github:GithubRepo:1:134018330
diff --git a/backend/plugins/github/e2e/snapshot_tables/cicd_tasks.csv b/backend/plugins/github/e2e/snapshot_tables/cicd_tasks.csv
index 240fa6863..208386e9c 100644
--- a/backend/plugins/github/e2e/snapshot_tables/cicd_tasks.csv
+++ b/backend/plugins/github/e2e/snapshot_tables/cicd_tasks.csv
@@ -1,16 +1,16 @@
id,name,pipeline_id,result,status,type,environment,duration_sec,started_date,finished_date,cicd_scope_id
-github:GithubJob:1:577324554:1924918171,deployubuntu,github:GithubRun:1:134018330:577324554,,DONE,,,125,2021-02-18T06:59:13.000+00:00,2021-02-18T07:01:18.000+00:00,github:GithubRepo:1:134018330
-github:GithubJob:1:577324554:1924918191,deploymacos,github:GithubRun:1:134018330:577324554,,DONE,,,117,2021-02-18T06:59:21.000+00:00,2021-02-18T07:01:18.000+00:00,github:GithubRepo:1:134018330
-github:GithubJob:1:577324554:1924918205,deploywindows,github:GithubRun:1:134018330:577324554,,DONE,DEPLOYMENT,PRODUCTION,114,2021-02-18T06:59:15.000+00:00,2021-02-18T07:01:09.000+00:00,github:GithubRepo:1:134018330
-github:GithubJob:1:577324554:1924918228,deployubuntu,github:GithubRun:1:134018330:577324554,,DONE,,,125,2021-02-18T06:59:13.000+00:00,2021-02-18T07:01:18.000+00:00,github:GithubRepo:1:134018330
-github:GithubJob:1:577324554:1924918243,deploymacos,github:GithubRun:1:134018330:577324554,,DONE,,,119,2021-02-18T06:59:19.000+00:00,2021-02-18T07:01:18.000+00:00,github:GithubRepo:1:134018330
-github:GithubJob:1:577324554:1924918261,deploywindows,github:GithubRun:1:134018330:577324554,,DONE,DEPLOYMENT,PRODUCTION,114,2021-02-18T06:59:15.000+00:00,2021-02-18T07:01:09.000+00:00,github:GithubRepo:1:134018330
+github:GithubJob:1:577324554:1924918171,deployubuntu,github:GithubRun:1:134018330:577324554,FAILURE,DONE,,,125,2021-02-18T06:59:13.000+00:00,2021-02-18T07:01:18.000+00:00,github:GithubRepo:1:134018330
+github:GithubJob:1:577324554:1924918191,deploymacos,github:GithubRun:1:134018330:577324554,FAILURE,DONE,,,117,2021-02-18T06:59:21.000+00:00,2021-02-18T07:01:18.000+00:00,github:GithubRepo:1:134018330
+github:GithubJob:1:577324554:1924918205,deploywindows,github:GithubRun:1:134018330:577324554,FAILURE,DONE,DEPLOYMENT,PRODUCTION,114,2021-02-18T06:59:15.000+00:00,2021-02-18T07:01:09.000+00:00,github:GithubRepo:1:134018330
+github:GithubJob:1:577324554:1924918228,deployubuntu,github:GithubRun:1:134018330:577324554,FAILURE,DONE,,,125,2021-02-18T06:59:13.000+00:00,2021-02-18T07:01:18.000+00:00,github:GithubRepo:1:134018330
+github:GithubJob:1:577324554:1924918243,deploymacos,github:GithubRun:1:134018330:577324554,FAILURE,DONE,,,119,2021-02-18T06:59:19.000+00:00,2021-02-18T07:01:18.000+00:00,github:GithubRepo:1:134018330
+github:GithubJob:1:577324554:1924918261,deploywindows,github:GithubRun:1:134018330:577324554,FAILURE,DONE,DEPLOYMENT,PRODUCTION,114,2021-02-18T06:59:15.000+00:00,2021-02-18T07:01:09.000+00:00,github:GithubRepo:1:134018330
github:GithubJob:1:577324558:1924918168,Golangci-Lint,github:GithubRun:1:134018330:577324558,SUCCESS,DONE,,,20,2021-02-18T06:59:13.000+00:00,2021-02-18T06:59:33.000+00:00,github:GithubRepo:1:134018330
github:GithubJob:1:577324571:1924918319,Analyze,github:GithubRun:1:134018330:577324571,SUCCESS,DONE,,,61,2021-02-18T06:59:16.000+00:00,2021-02-18T07:00:17.000+00:00,github:GithubRepo:1:134018330
github:GithubJob:1:577330055:1924932184,Analyze,github:GithubRun:1:134018330:577330055,SUCCESS,DONE,,,54,2021-02-18T07:02:02.000+00:00,2021-02-18T07:02:56.000+00:00,github:GithubRepo:1:134018330
github:GithubJob:1:577330056:1924932219,deployubuntu,github:GithubRun:1:134018330:577330056,SUCCESS,DONE,,,180,2021-02-18T07:02:03.000+00:00,2021-02-18T07:05:03.000+00:00,github:GithubRepo:1:134018330
-github:GithubJob:1:577330056:1924932237,deploymacos,github:GithubRun:1:134018330:577330056,,IN_PROGRESS,,,0,2021-02-18T07:02:06.000+00:00,2021-02-18T07:04:44.000+00:00,github:GithubRepo:1:134018330
-github:GithubJob:1:577330056:1924932251,deploywindows,github:GithubRun:1:134018330:577330056,,IN_PROGRESS,DEPLOYMENT,PRODUCTION,0,2021-02-18T07:02:03.000+00:00,2021-02-18T07:05:57.000+00:00,github:GithubRepo:1:134018330
+github:GithubJob:1:577330056:1924932237,deploymacos,github:GithubRun:1:134018330:577330056,,OTHER,,,0,2021-02-18T07:02:06.000+00:00,2021-02-18T07:04:44.000+00:00,github:GithubRepo:1:134018330
+github:GithubJob:1:577330056:1924932251,deploywindows,github:GithubRun:1:134018330:577330056,,OTHER,DEPLOYMENT,PRODUCTION,0,2021-02-18T07:02:03.000+00:00,2021-02-18T07:05:57.000+00:00,github:GithubRepo:1:134018330
github:GithubJob:1:577330056:1924932266,deployubuntu,github:GithubRun:1:134018330:577330056,SUCCESS,DONE,,,161,2021-02-18T07:02:03.000+00:00,2021-02-18T07:04:44.000+00:00,github:GithubRepo:1:134018330
github:GithubJob:1:577330056:1924932293,deploymacos,github:GithubRun:1:134018330:577330056,SUCCESS,DONE,,,158,2021-02-18T07:02:06.000+00:00,2021-02-18T07:04:44.000+00:00,github:GithubRepo:1:134018330
github:GithubJob:1:577330056:1924932319,deploywindows,github:GithubRun:1:134018330:577330056,SUCCESS,DONE,DEPLOYMENT,PRODUCTION,230,2021-02-18T07:02:03.000+00:00,2021-02-18T07:05:53.000+00:00,github:GithubRepo:1:134018330
diff --git a/backend/plugins/github/tasks/cicd_job_convertor.go b/backend/plugins/github/tasks/cicd_job_convertor.go
index 7041fb23e..1b48ef160 100644
--- a/backend/plugins/github/tasks/cicd_job_convertor.go
+++ b/backend/plugins/github/tasks/cicd_job_convertor.go
@@ -97,13 +97,14 @@ func ConvertJobs(taskCtx plugin.SubTaskContext) (err errors.Error) {
Type: line.Type,
Environment: line.Environment,
Result: devops.GetResult(&devops.ResultRule{
- Failed: []string{"failure"},
- Success: []string{"success"},
- Skipped: []string{"skipped", "NEUTRAL"},
+ Success: []string{StatusSuccess},
+ Failure: []string{StatusFailure, StatusCancelled, StatusTimedOut, StatusStartUpFailure},
+ Default: devops.RESULT_DEFAULT,
}, line.Conclusion),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- Done: []string{"completed", "COMPLETED"},
- Default: devops.STATUS_IN_PROGRESS,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{StatusCompleted, StatusSuccess, StatusFailure, StatusCancelled, StatusTimedOut, StatusStartUpFailure},
+ InProgress: []string{StatusInProgress, StatusQueued, StatusWaiting, StatusPending},
+ Default: devops.STATUS_OTHER,
}, line.Status),
}
diff --git a/backend/plugins/github/tasks/cicd_run_convertor.go b/backend/plugins/github/tasks/cicd_run_convertor.go
index c24016db2..d6967e865 100644
--- a/backend/plugins/github/tasks/cicd_run_convertor.go
+++ b/backend/plugins/github/tasks/cicd_run_convertor.go
@@ -98,13 +98,14 @@ func ConvertRuns(taskCtx plugin.SubTaskContext) errors.Error {
Type: line.Type,
Environment: line.Environment,
Result: devops.GetResult(&devops.ResultRule{
- Failed: []string{"failure"},
- Success: []string{"success"},
- Skipped: []string{"skipped"},
+ Success: []string{StatusSuccess},
+ Failure: []string{StatusFailure, StatusCancelled, StatusTimedOut, StatusStartUpFailure},
+ Default: devops.RESULT_DEFAULT,
}, line.Conclusion),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- Done: []string{"completed", "COMPLETED"},
- Default: devops.STATUS_IN_PROGRESS,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{StatusCompleted, StatusSuccess, StatusFailure, StatusCancelled, StatusTimedOut, StatusStartUpFailure},
+ InProgress: []string{StatusInProgress, StatusQueued, StatusWaiting, StatusPending},
+ Default: devops.STATUS_OTHER,
}, line.Status),
}
if domainPipeline.Status == devops.STATUS_DONE {
diff --git a/backend/plugins/github/tasks/deployment_convertor.go b/backend/plugins/github/tasks/deployment_convertor.go
index 17b3befb4..ca425e15a 100644
--- a/backend/plugins/github/tasks/deployment_convertor.go
+++ b/backend/plugins/github/tasks/deployment_convertor.go
@@ -75,19 +75,14 @@ func ConvertDeployment(taskCtx plugin.SubTaskContext) errors.Error {
CicdScopeId: deploymentScopeIdGen.Generate(githubDeployment.ConnectionId, githubDeployment.GithubId),
Name: githubDeployment.CommitOid,
Result: devops.GetResult(&devops.ResultRule{
- Success: []string{"SUCCESS"},
- Failed: []string{"ERROR", "FAILURE"},
- Abort: []string{"QUEUED", "ABANDONED", "DESTROYED", "INACTIVE"},
- Manual: []string{"WAITING", "PENDING", "ACTIVE", "IN_PROGRESS"},
- Skipped: []string{},
- Default: githubDeployment.LatestStatusState,
+ Success: []string{StatusSuccess},
+ Failure: []string{StatusError, StatusFailure},
+ Default: devops.RESULT_DEFAULT,
}, githubDeployment.State),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- InProgress: []string{"ACTIVE", "QUEUED", "IN_PROGRESS", "ABANDONED", "DESTROYED", "FAILURE", "INACTIVE"},
- NotStarted: []string{"PENDING"},
- Done: []string{"SUCCESS"},
- Manual: []string{"ERROR", "WAITING"},
- Default: githubDeployment.State,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{StatusSuccess, StatusError, StatusFailure},
+ InProgress: []string{StatusInProgress, StatusQueued, StatusWaiting, StatusPending},
+ Default: devops.STATUS_OTHER,
}, githubDeployment.State),
Environment: githubDeployment.Environment,
CreatedDate: githubDeployment.CreatedDate,
diff --git a/backend/plugins/github/tasks/shared.go b/backend/plugins/github/tasks/shared.go
index e92e58fca..4406155f3 100644
--- a/backend/plugins/github/tasks/shared.go
+++ b/backend/plugins/github/tasks/shared.go
@@ -26,6 +26,33 @@ import (
"net/http"
)
+const (
+ // https://docs.github.com/en/graphql/reference/enums#checkrunstate
+ // https://docs.github.com/en/graphql/reference/enums#checkstatusstate
+ // https://docs.github.com/en/graphql/reference/enums#deploymentstate
+ // https://docs.github.com/en/graphql/reference/enums#checkconclusionstate
+ StatusCompleted = "COMPLETED"
+ StatusSuccess = "SUCCESS"
+ StatusFailure = "FAILURE"
+ StatusCancelled = "CANCELLED"
+ StatusTimedOut = "TIMED_OUT"
+ StatusStartUpFailure = "STARTUP_FAILURE"
+ StatusInProgress = "IN_PROGRESS "
+ StatusQueued = "QUEUED"
+ StatusWaiting = "WAITING "
+ StatusPending = "PENDING"
+ StatusNeutral = "NEUTRAL"
+ StatusSkipped = "SKIPPED"
+ StatusStale = "STALE"
+ StatusActionRequired = "ACTION_REQUIRED"
+ StatusRequested = "REQUESTED"
+ StatusAbandoned = "ABANDONED"
+ StatusActive = "ACTIVE"
+ StatusInactive = "INACTIVE"
+ StatusDestroyed = "DESTROYED"
+ StatusError = "ERROR"
+)
+
func GetTotalPagesFromResponse(res *http.Response, args *api.ApiCollectorArgs) (int, errors.Error) {
link := res.Header.Get("link")
pageInfo, err := utils.GetPagingFromLinkHeader(link)
diff --git a/backend/plugins/gitlab/e2e/snapshot_tables/cicd_tasks.csv b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_tasks.csv
index 2e30b786b..d1715cf37 100644
--- a/backend/plugins/gitlab/e2e/snapshot_tables/cicd_tasks.csv
+++ b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_tasks.csv
@@ -55,8 +55,8 @@ gitlab:GitlabJob:1:152,format,gitlab:GitlabPipeline:1:73,FAILURE,DONE,,,0,2022-0
gitlab:GitlabJob:1:86,format,gitlab:GitlabPipeline:1:16,FAILURE,DONE,,,0,2022-07-25T13:40:42.020+00:00,2022-07-25T13:40:42.892+00:00,gitlab:GitlabProject:1:44
gitlab:GitlabJob:1:87,format,gitlab:GitlabPipeline:1:16,FAILURE,DONE,,,0,2022-07-25T13:41:11.601+00:00,2022-07-25T13:41:11.932+00:00,gitlab:GitlabProject:1:44
gitlab:GitlabJob:1:88,format,gitlab:GitlabPipeline:1:17,FAILURE,DONE,,,0,2022-07-25T13:42:59.674+00:00,2022-07-25T13:42:59.998+00:00,gitlab:GitlabProject:1:44
-gitlab:GitlabJob:1:89,format,gitlab:GitlabPipeline:1:17,ABORT,DONE,,,0,2022-07-25T13:46:15.482+00:00,2022-07-25T13:49:42.952+00:00,gitlab:GitlabProject:1:44
-gitlab:GitlabJob:1:90,format,gitlab:GitlabPipeline:1:18,ABORT,DONE,,,0,2022-07-25T13:50:40.680+00:00,2022-07-25T14:19:03.023+00:00,gitlab:GitlabProject:1:44
+gitlab:GitlabJob:1:89,format,gitlab:GitlabPipeline:1:17,FAILURE,OTHER,,,0,2022-07-25T13:46:15.482+00:00,2022-07-25T13:49:42.952+00:00,gitlab:GitlabProject:1:44
+gitlab:GitlabJob:1:90,format,gitlab:GitlabPipeline:1:18,FAILURE,OTHER,,,0,2022-07-25T13:50:40.680+00:00,2022-07-25T14:19:03.023+00:00,gitlab:GitlabProject:1:44
gitlab:GitlabJob:1:91,format,gitlab:GitlabPipeline:1:18,FAILURE,DONE,,,2,2022-07-25T14:26:02.616+00:00,2022-07-25T14:26:05.480+00:00,gitlab:GitlabProject:1:44
gitlab:GitlabJob:1:92,format,gitlab:GitlabPipeline:1:18,FAILURE,DONE,,,1,2022-07-25T14:47:12.876+00:00,2022-07-25T14:47:14.295+00:00,gitlab:GitlabProject:1:44
gitlab:GitlabJob:1:93,format,gitlab:GitlabPipeline:1:19,FAILURE,DONE,,,1,2022-07-25T14:53:56.227+00:00,2022-07-25T14:53:57.910+00:00,gitlab:GitlabProject:1:44
diff --git a/backend/plugins/gitlab/e2e/snapshot_tables/cicd_tasks_no_prod_regex.csv b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_tasks_no_prod_regex.csv
index abc6d6aa9..16d110951 100644
--- a/backend/plugins/gitlab/e2e/snapshot_tables/cicd_tasks_no_prod_regex.csv
+++ b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_tasks_no_prod_regex.csv
@@ -55,8 +55,8 @@ gitlab:GitlabJob:1:152,format,gitlab:GitlabPipeline:1:73,FAILURE,DONE,,PRODUCTIO
gitlab:GitlabJob:1:86,format,gitlab:GitlabPipeline:1:16,FAILURE,DONE,,PRODUCTION,0,2022-07-25T13:40:42.020+00:00,2022-07-25T13:40:42.892+00:00,gitlab:GitlabProject:1:44
gitlab:GitlabJob:1:87,format,gitlab:GitlabPipeline:1:16,FAILURE,DONE,,PRODUCTION,0,2022-07-25T13:41:11.601+00:00,2022-07-25T13:41:11.932+00:00,gitlab:GitlabProject:1:44
gitlab:GitlabJob:1:88,format,gitlab:GitlabPipeline:1:17,FAILURE,DONE,,PRODUCTION,0,2022-07-25T13:42:59.674+00:00,2022-07-25T13:42:59.998+00:00,gitlab:GitlabProject:1:44
-gitlab:GitlabJob:1:89,format,gitlab:GitlabPipeline:1:17,ABORT,DONE,,PRODUCTION,0,2022-07-25T13:46:15.482+00:00,2022-07-25T13:49:42.952+00:00,gitlab:GitlabProject:1:44
-gitlab:GitlabJob:1:90,format,gitlab:GitlabPipeline:1:18,ABORT,DONE,,PRODUCTION,0,2022-07-25T13:50:40.680+00:00,2022-07-25T14:19:03.023+00:00,gitlab:GitlabProject:1:44
+gitlab:GitlabJob:1:89,format,gitlab:GitlabPipeline:1:17,FAILURE,OTHER,,PRODUCTION,0,2022-07-25T13:46:15.482+00:00,2022-07-25T13:49:42.952+00:00,gitlab:GitlabProject:1:44
+gitlab:GitlabJob:1:90,format,gitlab:GitlabPipeline:1:18,FAILURE,OTHER,,PRODUCTION,0,2022-07-25T13:50:40.680+00:00,2022-07-25T14:19:03.023+00:00,gitlab:GitlabProject:1:44
gitlab:GitlabJob:1:91,format,gitlab:GitlabPipeline:1:18,FAILURE,DONE,,PRODUCTION,2,2022-07-25T14:26:02.616+00:00,2022-07-25T14:26:05.480+00:00,gitlab:GitlabProject:1:44
gitlab:GitlabJob:1:92,format,gitlab:GitlabPipeline:1:18,FAILURE,DONE,,PRODUCTION,1,2022-07-25T14:47:12.876+00:00,2022-07-25T14:47:14.295+00:00,gitlab:GitlabProject:1:44
gitlab:GitlabJob:1:93,format,gitlab:GitlabPipeline:1:19,FAILURE,DONE,,PRODUCTION,1,2022-07-25T14:53:56.227+00:00,2022-07-25T14:53:57.910+00:00,gitlab:GitlabProject:1:44
diff --git a/backend/plugins/gitlab/tasks/deployment_convertor.go b/backend/plugins/gitlab/tasks/deployment_convertor.go
index 7022b52ae..e5fafcbe9 100644
--- a/backend/plugins/gitlab/tasks/deployment_convertor.go
+++ b/backend/plugins/gitlab/tasks/deployment_convertor.go
@@ -94,18 +94,14 @@ func ConvertDeployment(taskCtx plugin.SubTaskContext) errors.Error {
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"},
- Abort: []string{"created", "canceled"},
- Manual: []string{"running", "blocked"},
- Default: gitlabDeployment.Status,
+ Success: []string{StatusSuccess, StatusCompleted},
+ Failure: []string{StatusCanceled, StatusFailed},
+ Default: devops.RESULT_DEFAULT,
}, gitlabDeployment.Status),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- Done: []string{"COMPLETED", "UNDEPLOYED", "failed", "success", "canceled"},
- InProgress: []string{"running"},
- NotStarted: []string{"created"},
- Manual: []string{"blocked"},
- Default: gitlabDeployment.Status,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{StatusSuccess, StatusCompleted, StatusFailed},
+ InProgress: []string{StatusRunning, StatusCanceled, StatusBlocked},
+ Default: devops.STATUS_OTHER,
}, gitlabDeployment.Status),
Environment: gitlabDeployment.Environment,
CreatedDate: gitlabDeployment.CreatedDate,
diff --git a/backend/plugins/gitlab/tasks/job_convertor.go b/backend/plugins/gitlab/tasks/job_convertor.go
index b8bbacb09..17837fbb1 100644
--- a/backend/plugins/gitlab/tasks/job_convertor.go
+++ b/backend/plugins/gitlab/tasks/job_convertor.go
@@ -85,17 +85,14 @@ func ConvertJobs(taskCtx plugin.SubTaskContext) (err errors.Error) {
Name: gitlabJob.Name,
PipelineId: pipelineIdGen.Generate(data.Options.ConnectionId, gitlabJob.PipelineId),
Result: devops.GetResult(&devops.ResultRule{
- Failed: []string{"failed"},
- Abort: []string{"canceled"},
- Manual: []string{"manual"},
- Success: []string{"success"},
- Skipped: []string{"skipped"},
- Default: "",
+ Success: []string{StatusSuccess, StatusCompleted},
+ Failure: []string{StatusCanceled, StatusFailed},
+ Default: devops.RESULT_DEFAULT,
}, gitlabJob.Status),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- InProgress: []string{"created", "waiting_for_resource", "preparing", "pending", "running", "scheduled"},
- Manual: []string{"manual"},
- Default: devops.STATUS_DONE,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{StatusSuccess, StatusCompleted, StatusFailed},
+ InProgress: []string{StatusRunning, StatusWaitingForResource, StatusPreparing, StatusPending},
+ Default: devops.STATUS_OTHER,
}, gitlabJob.Status),
DurationSec: uint64(gitlabJob.Duration),
diff --git a/backend/plugins/gitlab/tasks/pipeline_convertor.go b/backend/plugins/gitlab/tasks/pipeline_convertor.go
index 5c065b1d1..a874fe11c 100644
--- a/backend/plugins/gitlab/tasks/pipeline_convertor.go
+++ b/backend/plugins/gitlab/tasks/pipeline_convertor.go
@@ -86,15 +86,14 @@ func ConvertPipelines(taskCtx plugin.SubTaskContext) errors.Error {
},
Name: pipelineIdGen.Generate(data.Options.ConnectionId, gitlabPipeline.GitlabId),
Result: devops.GetResult(&devops.ResultRule{
- Failed: []string{"failed"},
- Abort: []string{"canceled"},
- Success: []string{"success"},
- Skipped: []string{"skipped"},
- Default: "",
+ Success: []string{StatusSuccess, StatusCompleted},
+ Failure: []string{StatusFailed, StatusCanceled},
+ Default: devops.RESULT_DEFAULT,
}, gitlabPipeline.Status),
- Status: devops.GetStatus(&devops.StatusRule[string]{
- InProgress: []string{"created", "waiting_for_resource", "preparing", "pending", "running", "manual", "scheduled"},
- Default: devops.STATUS_DONE,
+ Status: devops.GetStatus(&devops.StatusRule{
+ Done: []string{StatusSuccess, StatusCompleted, StatusFailed, StatusCanceled},
+ InProgress: []string{StatusRunning, StatusWaitingForResource, StatusPending, StatusPreparing},
+ Default: devops.STATUS_OTHER,
}, gitlabPipeline.Status),
CreatedDate: startedAt,
FinishedDate: gitlabPipeline.GitlabUpdatedAt,
diff --git a/backend/plugins/gitlab/tasks/shared.go b/backend/plugins/gitlab/tasks/shared.go
index 7f1e3e8c1..8446a2a2c 100644
--- a/backend/plugins/gitlab/tasks/shared.go
+++ b/backend/plugins/gitlab/tasks/shared.go
@@ -36,6 +36,27 @@ import (
helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
)
+const (
+ // https://docs.gitlab.com/ee/api/pipelines.html#list-project-pipelines
+ // https://docs.gitlab.com/ee/api/deployments.html#list-project-deployments
+ // https://docs.gitlab.com/ee/api/jobs.html#list-project-jobs
+ StatusSuccess = "success"
+ StatusFailed = "failed"
+ StatusCanceled = "canceled"
+ StatusRunning = "running"
+ StatusWaitingForResource = "waiting_for_resource"
+ StatusPending = "pending"
+ StatusPreparing = "preparing"
+ StatusCreated = "created"
+ StatusManual = "manual"
+ StatusScheduled = "scheduled"
+ StatusSkipped = "skipped"
+ StatusBlocked = "blocked"
+ // the following two status are handle in codes, but cannot be seen in documents.
+ StatusCompleted = "COMPLETED"
+ StatusUndeployed = "UNDEPLOYED"
+)
+
type GitlabInput struct {
GitlabId int
Iid int
diff --git a/backend/plugins/jenkins/e2e/snapshot_tables/cicd_tasks_after_stages.csv b/backend/plugins/jenkins/e2e/snapshot_tables/cicd_tasks_after_stages.csv
index 97c4e2f1f..7f5bf360a 100644
--- a/backend/plugins/jenkins/e2e/snapshot_tables/cicd_tasks_after_stages.csv
+++ b/backend/plugins/jenkins/e2e/snapshot_tables/cicd_tasks_after_stages.csv
@@ -1,8 +1,8 @@
id,name,pipeline_id,result,status,type,duration_sec,started_date,finished_date,environment,cicd_scope_id,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#10:8,scp-f/b,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#10,FAILURE,DONE,,0,2019-10-29T04:01:34.000+00:00,2019-10-29T04:01:34.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,13577,
-jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#11:9,gitlabInit,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#11,,IN_PROGRESS,,1312,2021-03-09T13:35:10.000+00:00,2021-03-09T13:57:02.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,13578,
+jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#11:9,gitlabInit,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#11,,OTHER,,1312,2021-03-09T13:35:10.000+00:00,2021-03-09T13:57:02.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,13578,
jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#12:1,gitlabAutoSync,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#12,SUCCESS,DONE,DEPLOYMENT,14,2020-02-07T11:54:28.000+00:00,2020-02-07T11:54:42.000+00:00,PRODUCTION,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins [...]
-jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#13:2,gitlabInit,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#13,ABORT,DONE,,5,2020-03-18T02:19:17.000+00:00,2020-03-18T02:19:22.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,13580,
+jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#13:2,gitlabInit,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#13,FAILURE,DONE,,5,2020-03-18T02:19:17.000+00:00,2020-03-18T02:19:22.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,13580,
jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#14:3,gitlabAutoSync,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#14,SUCCESS,DONE,DEPLOYMENT,83,2020-03-12T02:45:25.000+00:00,2020-03-12T02:46:48.000+00:00,PRODUCTION,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins [...]
jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#1:6,Hello,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#1,SUCCESS,DONE,,0,2022-09-08T15:40:34.000+00:00,2022-09-08T15:40:34.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,1,
jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#2:7,Hello,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#2,SUCCESS,DONE,,0,2022-09-08T15:40:49.000+00:00,2022-09-08T15:40:49.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,2,
@@ -12,4 +12,4 @@ jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/de
jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#6:11,Hello,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#6,SUCCESS,DONE,,0,2022-09-08T15:40:34.000+00:00,2022-09-08T15:40:34.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,6,
jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#7:12,gitlabInit,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#7,FAILURE,DONE,,0,2020-03-04T13:47:24.000+00:00,2020-03-04T13:47:24.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,13574,
jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#8:6,gitlabInit,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#8,FAILURE,DONE,,215,2020-03-17T15:27:15.000+00:00,2020-03-17T15:30:50.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,13575,
-jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#9:7,gitlabInit,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#9,ABORT,DONE,,5,2020-03-18T02:19:17.000+00:00,2020-03-18T02:19:22.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,13576,
+jenkins:JenkinsStage:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#9:7,gitlabInit,jenkins:JenkinsBuild:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake#9,FAILURE,DONE,,5,2020-03-18T02:19:17.000+00:00,2020-03-18T02:19:22.000+00:00,,jenkins:JenkinsJob:1:Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake,"{""ConnectionId"":1,""FullName"":""Test-jenkins-dir/test-jenkins-sub-dir/test-sub-sub-dir/devlake""}",_raw_jenkins_api_stages,13576,
diff --git a/backend/plugins/jenkins/tasks/build_cicd_convertor.go b/backend/plugins/jenkins/tasks/build_cicd_convertor.go
index 15d376d19..add8e510f 100644
--- a/backend/plugins/jenkins/tasks/build_cicd_convertor.go
+++ b/backend/plugins/jenkins/tasks/build_cicd_convertor.go
@@ -71,16 +71,17 @@ func ConvertBuildsToCicdTasks(taskCtx plugin.SubTaskContext) (err errors.Error)
Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
jenkinsBuild := inputRow.(*models.JenkinsBuild)
durationSec := int64(jenkinsBuild.Duration / 1000)
- jenkinsPipelineStatus := devops.GetStatus(&devops.StatusRule[bool]{
+ jenkinsPipelineStatus := devops.GetStatusCommon(&devops.StatusRuleCommon[bool]{
InProgress: []bool{true},
Done: []bool{false},
+ Default: devops.STATUS_OTHER,
}, jenkinsBuild.Building)
- var jenkinsPipelineResult string
+ jenkinsPipelineResult := devops.RESULT_DEFAULT
if !jenkinsBuild.Building {
jenkinsPipelineResult = devops.GetResult(&devops.ResultRule{
- Success: []string{"SUCCESS"},
- Failed: []string{"FAILURE"},
- Abort: []string{"ABORTED"},
+ Success: []string{SUCCESS},
+ Failure: []string{FAILURE, ABORTED},
+ Default: devops.RESULT_DEFAULT,
}, jenkinsBuild.Result)
}
var jenkinsPipelineFinishedDate *time.Time
diff --git a/backend/plugins/jenkins/tasks/shared.go b/backend/plugins/jenkins/tasks/shared.go
index 932e7f4c3..cdc42869c 100644
--- a/backend/plugins/jenkins/tasks/shared.go
+++ b/backend/plugins/jenkins/tasks/shared.go
@@ -23,6 +23,15 @@ import (
"net/http"
)
+const (
+ SUCCESS = "SUCCESS"
+ FAILURE = "FAILURE"
+ FAILED = "FAILED"
+ ABORTED = "ABORTED"
+ NOT_BUILD = "NOT_BUILD"
+ UNSTABLE = "UNSTABLE"
+)
+
func ignoreHTTPStatus404(res *http.Response) errors.Error {
if res.StatusCode == http.StatusUnauthorized {
return errors.Unauthorized.New("authentication failed, please check your AccessToken")
diff --git a/backend/plugins/jenkins/tasks/stage_convertor.go b/backend/plugins/jenkins/tasks/stage_convertor.go
index 91eca0a93..80769d4f1 100644
--- a/backend/plugins/jenkins/tasks/stage_convertor.go
+++ b/backend/plugins/jenkins/tasks/stage_convertor.go
@@ -65,8 +65,8 @@ func ConvertStages(taskCtx plugin.SubTaskContext) (err errors.Error) {
clauses := []dal.Clause{
dal.Select(`tjb.connection_id, tjs.build_name, tjs.id, tjs._raw_data_remark, tjs.name,
tjs._raw_data_id, tjs._raw_data_table, tjs._raw_data_params,
- tjs.status, tjs.start_time_millis, tjs.duration_millis,
- tjs.pause_duration_millis, tjs.type,
+ tjs.status, tjs.start_time_millis, tjs.duration_millis,
+ tjs.pause_duration_millis, tjs.type,
tjb.triggered_by, tjb.building`),
dal.From("_tool_jenkins_stages tjs"),
dal.Join("left join _tool_jenkins_builds tjb on tjs.build_name = tjb.full_name"),
@@ -100,21 +100,20 @@ func ConvertStages(taskCtx plugin.SubTaskContext) (err errors.Error) {
return nil, err
}
durationSec := int64(body.DurationMillis / 1000)
- jenkinsTaskResult := ""
- jenkinsTaskStatus := devops.STATUS_DONE
+ jenkinsTaskResult := devops.GetResult(&devops.ResultRule{
+ Success: []string{SUCCESS},
+ Failure: []string{FAILED, FAILURE, ABORTED},
+ Default: devops.RESULT_DEFAULT,
+ }, body.Status)
+
+ jenkinsTaskStatus := devops.GetStatus(&devops.StatusRule{
+ Done: []string{SUCCESS, FAILURE, FAILED, ABORTED},
+ InProgress: []string{},
+ Default: devops.STATUS_OTHER,
+ }, body.Status)
+
var jenkinsTaskFinishedDate *time.Time
results := make([]interface{}, 0)
- if body.Status == "SUCCESS" {
- jenkinsTaskResult = devops.RESULT_SUCCESS
- } else if body.Status == "FAILED" {
- jenkinsTaskResult = devops.RESULT_FAILURE
- } else if body.Status == "ABORTED" {
- jenkinsTaskResult = devops.RESULT_ABORT
- } else {
- jenkinsTaskResult = ""
- jenkinsTaskStatus = devops.STATUS_IN_PROGRESS
- }
-
startedDate := time.Unix(body.StartTimeMillis/1000, 0)
finishedDate := startedDate.Add(time.Duration(durationSec * int64(time.Second)))
jenkinsTaskFinishedDate = &finishedDate