Skip to content
Open
Show file tree
Hide file tree
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
26 changes: 20 additions & 6 deletions backend/core/models/domainlayer/devops/cicd_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ func (CICDPipeline) TableName() string {

// this is for the field `result` in table.cicd_pipelines and table.cicd_tasks
const (
RESULT_SUCCESS = "SUCCESS"
RESULT_FAILURE = "FAILURE"
RESULT_DEFAULT = ""
RESULT_SUCCESS = "SUCCESS"
RESULT_FAILURE = "FAILURE"
RESULT_CANCELED = "CANCELED"
RESULT_SKIPPED = "SKIPPED"
RESULT_DEFAULT = ""
)

// this is for the field `status` in table.cicd_pipelines and table.cicd_tasks
Expand All @@ -62,9 +64,11 @@ const (
)

type ResultRule struct {
Success []string
Failure []string
Default string
Success []string
Failure []string
Canceled []string
Skipped []string
Default string
}

type StatusRule struct {
Expand All @@ -91,6 +95,16 @@ func GetResult(rule *ResultRule, input interface{}) string {
return RESULT_FAILURE
}
}
for _, canceled := range rule.Canceled {
if strings.EqualFold(canceled, cast.ToString(input)) {
return RESULT_CANCELED
}
}
for _, skipped := range rule.Skipped {
if strings.EqualFold(skipped, cast.ToString(input)) {
return RESULT_SKIPPED
}
}
return rule.Default
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ azuredevops_go:AzuredevopsBuild:1:14,label_regex_test,SUCCESS,DONE,completed,suc
azuredevops_go:AzuredevopsBuild:1:15,label_regex_test_pro,SUCCESS,DONE,completed,succeeded,,31,,,2023-02-25T06:22:21.224+00:00,2023-02-25T06:22:21.224+00:00,2023-02-25T06:22:32.810+00:00,2023-02-25T06:23:04.006+00:00,azuredevops_go:AzuredevopsRepo:1:0d50ba13-f9ad-49b0-9b21-d29eda50ca33
azuredevops_go:AzuredevopsBuild:1:16,label_regex_test_pro,"",IN_PROGRESS,inProgress,"",,0,,,2023-02-25T06:22:21.224+00:00,2023-02-25T06:22:21.224+00:00,2023-02-25T06:22:32.810+00:00,"",azuredevops_go:AzuredevopsRepo:1:0d50ba13-f9ad-49b0-9b21-d29eda50ca33
azuredevops_go:AzuredevopsBuild:1:17,label_regex_test_pro,"",IN_PROGRESS,notStarted,"",,0,,,2023-02-25T06:22:21.224+00:00,"","","",azuredevops_go:AzuredevopsRepo:1:0d50ba13-f9ad-49b0-9b21-d29eda50ca33
azuredevops_go:AzuredevopsBuild:1:18,label_regex_test_pro,FAILURE,DONE,completed,canceled,,5,,,2023-02-25T06:22:21.224+00:00,2023-02-25T06:22:21.224+00:00,2023-02-25T06:22:25.224+00:00,2023-02-25T06:22:30.224+00:00,azuredevops_go:AzuredevopsRepo:1:0d50ba13-f9ad-49b0-9b21-d29eda50ca33
azuredevops_go:AzuredevopsBuild:1:18,label_regex_test_pro,CANCELED,DONE,completed,canceled,,5,,,2023-02-25T06:22:21.224+00:00,2023-02-25T06:22:21.224+00:00,2023-02-25T06:22:25.224+00:00,2023-02-25T06:22:30.224+00:00,azuredevops_go:AzuredevopsRepo:1:0d50ba13-f9ad-49b0-9b21-d29eda50ca33
24 changes: 14 additions & 10 deletions backend/plugins/azuredevops_go/tasks/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ package tasks
import (
"encoding/json"
"fmt"
"net/http"
"net/url"

"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/domainlayer/devops"
"github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"net/http"
"net/url"
)

// Build and TimeLine Record State and Result types can be found here:
Expand Down Expand Up @@ -109,25 +110,28 @@ func ExtractContToken(_ *api.RequestData, prevPageResponse *http.Response) (inte
}

var cicdBuildResultRule = devops.ResultRule{
Success: []string{succeeded},
Failure: []string{canceled, failed, none, partiallySucceeded},
Default: devops.RESULT_DEFAULT,
Success: []string{succeeded},
Failure: []string{failed, none, partiallySucceeded},
Canceled: []string{canceled},
Default: devops.RESULT_DEFAULT,
}

var cicdBuildStatusRule = devops.StatusRule{
Done: []string{completed, cancelling},
Done: []string{completed, cancelling, canceled},
InProgress: []string{inProgress, notStarted, postponed},
Default: devops.STATUS_OTHER,
}

var cicdTaskResultRule = &devops.ResultRule{
Success: []string{succeeded, succeededWithIssues},
Failure: []string{abandoned, canceled, failed, skipped},
Default: devops.RESULT_DEFAULT,
Success: []string{succeeded, succeededWithIssues},
Failure: []string{failed},
Canceled: []string{abandoned, canceled},
Skipped: []string{skipped},
Default: devops.RESULT_DEFAULT,
}

var cicdTaskStatusRule = &devops.StatusRule{
Done: []string{completed},
Done: []string{completed, abandoned, canceled, skipped},
InProgress: []string{pending, inProgress},
Default: devops.STATUS_OTHER,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ id,commit_sha,cicd_scope_id,cicd_deployment_id,name,display_title,url,result,sta
bamboo:deployBuildWithVcsRevision:1:130001:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130001:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,SUCCESS,DONE,FINISHED,SUCCESS,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130002:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130002:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,FAILURE,IN_PROGRESS,IN_PROGRESS,FAILED,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130003:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130003:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,,IN_PROGRESS,PENDING,REPLACED,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130004:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130004:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,,IN_PROGRESS,QUEUED,SKIPPED,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130004:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130004:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,SKIPPED,IN_PROGRESS,QUEUED,SKIPPED,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130005:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130005:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,,OTHER,NOT_BUILT,NEVER,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130006:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130006:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,,OTHER,NOT_BUILT,QUEUED,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130007:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130007:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,,OTHER,NOT_BUILT,IN PROGRESS,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ id,commit_sha,cicd_scope_id,cicd_deployment_id,name,display_title,url,result,sta
bamboo:deployBuildWithVcsRevision:1:130001:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130001:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,SUCCESS,DONE,FINISHED,SUCCESS,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130002:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130002:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,FAILURE,IN_PROGRESS,IN_PROGRESS,FAILED,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130003:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130003:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,,IN_PROGRESS,PENDING,REPLACED,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130004:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130004:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,,IN_PROGRESS,QUEUED,SKIPPED,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130004:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130004:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,SKIPPED,IN_PROGRESS,QUEUED,SKIPPED,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130005:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130005:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,,OTHER,NOT_BUILT,NEVER,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130006:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130006:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,,OTHER,NOT_BUILT,QUEUED,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
bamboo:deployBuildWithVcsRevision:1:130007:622595,79b062bd53af15c701193c90b543386557cb7a3a,bamboo:BambooPlan:1:TEST-PLA2,bamboo:deployBuildWithVcsRevision:1:130007:622595,test_project2 - test_plan/release-1,test_project2 - test_plan/release-1,,,OTHER,NOT_BUILT,IN PROGRESS,dev,dev,0,,,,622595,fake://127.0.0.1:8080/repos/622595,,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,12 @@ func ConvertDeployBuildsToDeploymentCommits(taskCtx plugin.SubTaskContext) error
Result: devops.GetResult(&devops.ResultRule{
Success: []string{ResultSuccess, ResultSuccessful},
Failure: []string{ResultFailed},
Skipped: []string{ResultSkipped},
Default: devops.RESULT_DEFAULT,
}, input.DeploymentState),
OriginalResult: input.DeploymentState,
Status: devops.GetStatus(&devops.StatusRule{
Done: []string{StatusFinished},
Done: []string{StatusFinished, ResultSkipped},
InProgress: []string{StatusInProgress, StatusPending, StatusQueued},
Default: devops.STATUS_OTHER,
}, input.LifeCycleState),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ func ConvertDeployBuildsToDeployments(taskCtx plugin.SubTaskContext) errors.Erro
Result: devops.GetResult(&devops.ResultRule{
Success: []string{ResultSuccess, ResultSuccessful},
Failure: []string{ResultFailed},
Skipped: []string{ResultSkipped},
Default: devops.RESULT_DEFAULT,
}, input.DeploymentState),
OriginalResult: input.DeploymentState,
Status: devops.GetStatus(&devops.StatusRule{
Done: []string{StatusFinished},
Done: []string{StatusFinished, ResultSkipped},
InProgress: []string{StatusInProgress, StatusPending, StatusQueued},
Default: devops.STATUS_OTHER,
}, input.LifeCycleState),
Expand Down
3 changes: 2 additions & 1 deletion backend/plugins/bamboo/tasks/job_build_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ func ConvertJobBuilds(taskCtx plugin.SubTaskContext) errors.Error {
Result: devops.GetResult(&devops.ResultRule{
Success: []string{ResultSuccess, ResultSuccessful},
Failure: []string{ResultFailed},
Skipped: []string{ResultSkipped},
Default: devops.RESULT_DEFAULT,
}, line.BuildState),
OriginalResult: line.BuildState,
Status: devops.GetStatus(&devops.StatusRule{
Done: []string{StatusFinished},
Done: []string{StatusFinished, ResultSkipped},
InProgress: []string{StatusInProgress, StatusPending, StatusQueued},
Default: devops.STATUS_OTHER,
}, line.LifeCycleState),
Expand Down
3 changes: 2 additions & 1 deletion backend/plugins/bamboo/tasks/plan_build_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ func ConvertPlanBuilds(taskCtx plugin.SubTaskContext) errors.Error {
Result: devops.GetResult(&devops.ResultRule{
Success: []string{ResultSuccess, ResultSuccessful},
Failure: []string{ResultFailed},
Skipped: []string{ResultSkipped},
Default: devops.RESULT_DEFAULT,
}, line.BuildState),
OriginalResult: line.BuildState,
Status: devops.GetStatus(&devops.StatusRule{
Done: []string{StatusFinished},
Done: []string{StatusFinished, ResultSkipped},
InProgress: []string{StatusInProgress, StatusPending, StatusQueued},
Default: devops.STATUS_OTHER,
}, line.LifeCycleState),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4101},83ed48081
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4102},83ed48081d1fad9dbd60948cfe9661f67aac2694,#7,SUCCESS,DONE,,SUCCESSFUL,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4103},83ed48081d1fad9dbd60948cfe9661f67aac2694,#7,FAILURE,DONE,,FAILED,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4104},83ed48081d1fad9dbd60948cfe9661f67aac2694,#7,FAILURE,DONE,,STOPPED,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4105},83ed48081d1fad9dbd60948cfe9661f67aac2694,#7,FAILURE,DONE,,CANCELLED,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4105},83ed48081d1fad9dbd60948cfe9661f67aac2694,#7,CANCELED,DONE,,CANCELLED,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4106},83ed48081d1fad9dbd60948cfe9661f67aac2694,#7,,IN_PROGRESS,,IN_PROGRESS,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4107},83ed48081d1fad9dbd60948cfe9661f67aac2694,#7,,OTHER,,UNDEPLOYED,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4108},83ed48081d1fad9dbd60948cfe9661f67aac2694,#7,,OTHER,,PENDING,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4101},#7,SUCCES
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4102},#7,SUCCESS,DONE,,SUCCESSFUL,PRODUCTION,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4103},#7,FAILURE,DONE,,FAILED,PRODUCTION,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4104},#7,FAILURE,DONE,,STOPPED,PRODUCTION,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4105},#7,FAILURE,DONE,,CANCELLED,PRODUCTION,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4105},#7,CANCELED,DONE,,CANCELLED,PRODUCTION,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4106},#7,,IN_PROGRESS,,IN_PROGRESS,PRODUCTION,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4107},#7,,OTHER,,UNDEPLOYED,PRODUCTION,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
bitbucket:BitbucketDeployment:1:{5c6b00c4-a848-5db6-b9e1-3912631d4108},#7,,OTHER,,PENDING,PRODUCTION,PRODUCTION,#7,https://bitbucket.org/likyh/likyhphp/addon/pipelines/home#!/results/7
Expand Down
Loading
Loading