diff --git a/CHANGELOG.md b/CHANGELOG.md index b3b6840..e958ba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Optional `source.omit_target_url`. If set to true, will omit the GitHub Commit status API `target_url` (see README). - pkg/sets: add Intersect() and Add() methods. ## [v0.12.1] - 2024-04-03 diff --git a/README.md b/README.md index 34f1017..61aae8e 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,10 @@ With reference to the [GitHub Commit status API], the `POST` parameters (`state` GitHub hostname. This allows to post commit statuses to repositories hosted by GitHub Enterprise (GHE) instances. For example: github.mycompany.org will be expanded by cogito to https://github.mycompany.org/api/v3 \ Default: `github.com` +- `omit_target_url`:\ + If set to true, will omit the GitHub Commit status API `target_url` (the URL to the build on Concourse).\n + Default: `false`. + - `log_url`. **DEPRECATED, no-op, will be removed**\ A Google Hangout Chat webhook. Useful to obtain logging for the `check` step for Concourse < v7.x diff --git a/cogito/ghcommitsink.go b/cogito/ghcommitsink.go index 9407966..df33a4b 100644 --- a/cogito/ghcommitsink.go +++ b/cogito/ghcommitsink.go @@ -54,6 +54,9 @@ func (sink GitHubCommitStatusSink) Send() error { "state", ghState, "owner", sink.Request.Source.Owner, "repo", sink.Request.Source.Repo, "git-ref", sink.GitRef, "context", context, "buildURL", buildURL, "description", description) + if sink.Request.Source.OmitTargetURL { + buildURL = "" + } if err := commitStatus.Add(sink.GitRef, ghState, buildURL, description); err != nil { return err } diff --git a/cogito/protocol.go b/cogito/protocol.go index 12d66a5..85aa9de 100644 --- a/cogito/protocol.go +++ b/cogito/protocol.go @@ -173,6 +173,7 @@ type Source struct { LogLevel string `json:"log_level"` LogUrl string `json:"log_url"` // DEPRECATED ContextPrefix string `json:"context_prefix"` + OmitTargetURL bool `json:"omit_target_url"` ChatAppendSummary bool `json:"chat_append_summary"` ChatNotifyOnStates []BuildState `json:"chat_notify_on_states"` Sinks []string `json:"sinks"` @@ -189,6 +190,7 @@ func (src Source) String() string { fmt.Fprintf(&bld, "gchat_webhook: %s\n", redact(src.GChatWebHook)) fmt.Fprintf(&bld, "log_level: %s\n", src.LogLevel) fmt.Fprintf(&bld, "context_prefix: %s\n", src.ContextPrefix) + fmt.Fprintf(&bld, "omit_target_url: %t\n", src.OmitTargetURL) fmt.Fprintf(&bld, "chat_append_summary: %t\n", src.ChatAppendSummary) fmt.Fprintf(&bld, "chat_notify_on_states: %s\n", src.ChatNotifyOnStates) // Last one: no newline. @@ -253,7 +255,6 @@ func (src *Source) Validate() error { if src.GChatWebHook == "" { mandatory = append(mandatory, "gchat_webhook") } - } if len(mandatory) > 0 { diff --git a/cogito/protocol_test.go b/cogito/protocol_test.go index 289848b..5ff00e8 100644 --- a/cogito/protocol_test.go +++ b/cogito/protocol_test.go @@ -219,6 +219,7 @@ access_token: ***REDACTED*** gchat_webhook: ***REDACTED*** log_level: debug context_prefix: the-prefix +omit_target_url: false chat_append_summary: true chat_notify_on_states: [success failure] sinks: []` @@ -239,6 +240,7 @@ access_token: gchat_webhook: log_level: context_prefix: +omit_target_url: false chat_append_summary: false chat_notify_on_states: [] sinks: []`