Skip to content

Commit

Permalink
Make git notes not trigger jenkins pipeline (#1288)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElfenB authored Jul 16, 2024
1 parent ac7543c commit e0f2cb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

### Added
- Added webhook proxy logic to skip requests with the ref id starting with "refs/notes/"

### Changed
- Update SonarQube to 9.9.6 ([#1292](https://github.com/opendevstack/ods-core/pull/1292))
Expand Down
10 changes: 10 additions & 0 deletions jenkins/webhook-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,16 @@ func (s *Server) HandleRoot() http.HandlerFunc {
return
}

// Skip requests with where the ref id is starting with "refs/notes/"
// Reference 1: https://community.atlassian.com/t5/Bitbucket-questions/disable-quot-git-notes-add-quot-behaviour-for-semantic-release/qaq-p/1837322
// Reference 2: https://github.com/semantic-release/semantic-release/discussions/2017#discussioncomment-995308
if len(req.Changes) > 0 && strings.Contains(req.Changes[0].Ref.DisplayID, "refs/notes/") {
log.Println(requestID, "Skipping request with refs/notes/ prefix in ref id")
// Return 200 OK to Bitbucket to avoid retries
http.Error(w, "OK", http.StatusOK)
return
}

if req.EventKey == "repo:refs_changed" {
repo = req.Repository.Slug
if component == "" {
Expand Down

0 comments on commit e0f2cb7

Please sign in to comment.