diff --git a/docs/config/plugins/github-com-jenkins-x-lighthouse-pkg-plugins.md b/docs/config/plugins/github-com-jenkins-x-lighthouse-pkg-plugins.md index d3f8f082e..7468beb9f 100644 --- a/docs/config/plugins/github-com-jenkins-x-lighthouse-pkg-plugins.md +++ b/docs/config/plugins/github-com-jenkins-x-lighthouse-pkg-plugins.md @@ -212,6 +212,7 @@ Trigger specifies a configuration for a single trigger.

The configura | `ignore_ok_to_test` | bool | No | IgnoreOkToTest makes trigger ignore /ok-to-test comments.
This is a security mitigation to only allow testing from trusted users. | | `elide_skipped_contexts` | bool | No | ElideSkippedContexts makes trigger not post "Skipped" contexts for jobs
that could run but do not run. | | `skip_draft_pr` | bool | No | SkipDraftPR when enabled, skips triggering pipelines for draft PRs
unless /ok-to-test is added. | +| `skip_report_comment` | bool | No | SkipReportComment when enabled, skips report comments in the SCM provider based on the state of
the LighthouseJobs. | ## Welcome diff --git a/docs/plugins/Plugins config.md b/docs/plugins/Plugins config.md index 359e7e0e5..f6465adc6 100644 --- a/docs/plugins/Plugins config.md +++ b/docs/plugins/Plugins config.md @@ -217,6 +217,7 @@ Trigger specifies a configuration for a single trigger.

The configura | IgnoreOkToTest | `ignore_ok_to_test` | bool | No | IgnoreOkToTest makes trigger ignore /ok-to-test comments.
This is a security mitigation to only allow testing from trusted users. | | ElideSkippedContexts | `elide_skipped_contexts` | bool | No | ElideSkippedContexts makes trigger not post "Skipped" contexts for jobs
that could run but do not run. | | SkipDraftPR | `skip_draft_pr` | bool | No | SkipDraftPR when enabled, skips triggering pipelines for draft PRs
unless /ok-to-test is added. | +| SkipReportComment | `skip_report_comment` | bool | No | SkipReportComment when enabled, skips report comments in the SCM provider based on the state of
the LighthouseJobs. | ## Welcome diff --git a/go.mod b/go.mod index 6ea5a4cc2..5531e74a4 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/h2non/gock v1.0.9 github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/golang-lru v0.5.4 - github.com/jenkins-x/go-scm v1.14.36 + github.com/jenkins-x/go-scm v1.14.37 github.com/mattn/go-zglob v0.0.1 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.20.1 @@ -127,7 +127,7 @@ replace ( github.com/Azure/azure-sdk-for-go => github.com/Azure/azure-sdk-for-go v38.2.0+incompatible // lets override the go-scm version from tektoncd - github.com/jenkins-x/go-scm => github.com/jenkins-x/go-scm v1.14.36 + github.com/jenkins-x/go-scm => github.com/jenkins-x/go-scm v1.14.37 // gomodules.xyz breaks in Athens proxying gomodules.xyz/jsonpatch/v2 => github.com/gomodules/jsonpatch/v2 v2.2.0 diff --git a/go.sum b/go.sum index dd9216edb..7414fd4e7 100644 --- a/go.sum +++ b/go.sum @@ -251,6 +251,8 @@ github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/jenkins-x/go-scm v1.14.36 h1:JbEt2BIq1v/Jnbd+DW3zEAO4ZjONB53guF8OfxaARDY= github.com/jenkins-x/go-scm v1.14.36/go.mod h1:MRLj/i0mhpMtqwwZV+x78SkEB8mx9rv3ebdRg9WunS8= +github.com/jenkins-x/go-scm v1.14.37 h1:Tq59JXyg5p4iuvIKf6+EA+Yzgxgpn/yG/yfM1mL8DDg= +github.com/jenkins-x/go-scm v1.14.37/go.mod h1:MRLj/i0mhpMtqwwZV+x78SkEB8mx9rv3ebdRg9WunS8= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= diff --git a/pkg/foghorn/controller.go b/pkg/foghorn/controller.go index 06434165c..fc6326583 100644 --- a/pkg/foghorn/controller.go +++ b/pkg/foghorn/controller.go @@ -264,11 +264,14 @@ func (r *LighthouseJobReconciler) reportStatus(activity *lighthousev1alpha1.Acti return } - err = reporter.Report(scmClient, r.jobConfig.Config().Plank.ReportTemplate, j, []job.PipelineKind{job.PresubmitJob}) - if err != nil { - // For now, we're just going to ignore failures here. - r.logger.WithFields(fields).WithError(err).Warnf("failed to update comments on the PR") + if !r.pluginConfig.Config().TriggerFor(owner, repo).SkipReportComment { + err = reporter.Report(scmClient, r.jobConfig.Config().Plank.ReportTemplate, j, []job.PipelineKind{job.PresubmitJob}) + if err != nil { + // For now, we're just going to ignore failures here. + r.logger.WithFields(fields).WithError(err).Warnf("failed to update comments on the PR") + } } + r.logger.WithFields(fields).Info("reported git status") j.Status.Description = statusInfo.description j.Status.LastReportState = statusInfo.scmStatus.String() diff --git a/pkg/plugins/config.go b/pkg/plugins/config.go index e30674996..5aafb35f9 100644 --- a/pkg/plugins/config.go +++ b/pkg/plugins/config.go @@ -289,6 +289,9 @@ type Trigger struct { ElideSkippedContexts bool `json:"elide_skipped_contexts,omitempty"` // SkipDraftPR when enabled, skips triggering pipelines for draft PRs, unless /ok-to-test is added. SkipDraftPR bool `json:"skip_draft_pr,omitempty"` + // SkipReportComment when enabled, skips report comments in the SCM provider based on the state of + // the LighthouseJobs. + SkipReportComment bool `json:"skip_report_comment,omitempty"` } // Milestone contains the configuration options for the milestone and