diff --git a/.gitignore b/.gitignore index 87bcbf9..9e88c76 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ /charts/batchv1-chart/* !/charts/batchv1-chart/Makefile !/charts/batchv1-chart/values.override.yaml -!/charts/batchv1-chart/README.md.gotmpl \ No newline at end of file +!/charts/batchv1-chart/README.md.gotmpl +.idea + diff --git a/pkgs/contract/pipeline.go b/pkgs/contract/pipeline.go index 53d63dc..aba7d88 100644 --- a/pkgs/contract/pipeline.go +++ b/pkgs/contract/pipeline.go @@ -4,11 +4,12 @@ import ( "crypto/sha256" "encoding/hex" "fmt" - "github.com/pkg/errors" - "k8s.io/apimachinery/pkg/labels" "net/url" "strings" "time" + + "github.com/pkg/errors" + "k8s.io/apimachinery/pkg/labels" ) type ConfigurationData interface { @@ -23,7 +24,6 @@ type PipelineInfo struct { instanceName string namespace string dateStarted time.Time - status Status stages []PipelineStage dashboardUrl string retrievalNum int @@ -204,6 +204,7 @@ const ( PipelineErrored Status = "errored" PipelineSucceeded Status = "succeeded" PipelineCancelled Status = "cancelled" + PipelineSkipped Status = "skipped" ) func (s Status) IsFinished() bool { @@ -214,6 +215,10 @@ func (s Status) IsRunning() bool { return s == PipelineRunning } +func (s Status) IsSkipped() bool { + return s == PipelineSkipped +} + func (s Status) IsErroredOrFailed() bool { return s == PipelineFailed || s == PipelineErrored } @@ -233,8 +238,10 @@ func (s Status) IsNotStarted() bool { func (s Status) AsHumanReadableDescription() string { if s == PipelineRunning || s == PipelinePending { return "is " + string(s) - } else if s == PipelineFailed || s == PipelineErrored || s == PipelineSucceeded || s == PipelineCancelled { + } else if s == PipelineFailed || s == PipelineErrored || s == PipelineSucceeded { return string(s) + } else if s == PipelineSkipped || s == PipelineCancelled { + return "was " + string(s) } return "is in unknown state" } diff --git a/pkgs/feedback/jxscm/receiver.go b/pkgs/feedback/jxscm/receiver.go index 2e72e51..f217c48 100644 --- a/pkgs/feedback/jxscm/receiver.go +++ b/pkgs/feedback/jxscm/receiver.go @@ -3,6 +3,9 @@ package jxscm import ( "context" "fmt" + "strconv" + "strings" + "github.com/jenkins-x/go-scm/scm" "github.com/kube-cicd/pipelines-feedback-core/internal/feedback/jxscm" "github.com/kube-cicd/pipelines-feedback-core/pkgs/config" @@ -11,8 +14,6 @@ import ( "github.com/kube-cicd/pipelines-feedback-core/pkgs/logging" "github.com/kube-cicd/pipelines-feedback-core/pkgs/templating" "github.com/pkg/errors" - "strconv" - "strings" ) const defaultProgressComment = ` @@ -218,7 +219,7 @@ func (jx *Receiver) UpdateProgress(ctx context.Context, pipeline contract.Pipeli scmCtx := pipeline.GetSCMContext() ourStatus := pipeline.GetStatus() - overallStatus := jx.translateStatus(ourStatus, cfg) + overallStatus := jx.translateStatus(ourStatus) // Update status in PR/MR comment var prCommentStatusErr error = nil @@ -280,7 +281,7 @@ func (jx *Receiver) updateCommitStatus(ctx context.Context, cfg config.Data, cli return commitStatusErr } -func (jx *Receiver) translateStatus(status contract.Status, cfg config.Data) scm.State { +func (jx *Receiver) translateStatus(status contract.Status) scm.State { switch status { case contract.PipelineRunning: return scm.StateRunning @@ -290,6 +291,8 @@ func (jx *Receiver) translateStatus(status contract.Status, cfg config.Data) scm return scm.StateSuccess case contract.PipelineErrored: return scm.StateError + case contract.PipelineSkipped: + return scm.StateCanceled case contract.PipelineFailed: return scm.StateFailure default: