opendevstack / ods-jenkins-shared-library

Shared Jenkins library which all ODS projects & components use - provisioning, SonarQube code scanning, Nexus publishing, OpenShift template based deployments and repository orchestration
Apache License 2.0
69 stars 57 forks source link

Workaround for bitbucket trouble with git-notes #1111

Closed ElfenB closed 1 month ago

ElfenB commented 1 month ago

Context: Bitbucket is generating ghost commits that have the commit message "Notes added by 'git notes add'" if git-notes is used (e.g. with semantic-release). To prevent Jenkins starting builds that will result in failure because there is nothing to build, the build should be stopped when those commits are coming in. Reference: https://github.com/semantic-release/semantic-release/discussions/2017#discussioncomment-995308

braisvq1996 commented 1 month ago

@ElfenB , I just tested git notes in BItbucket with an EDP project and this change will not fix your issue. The branch that triggers the build does not even exists but still triggers the webhook on the Bitbucket repository and consecuent also the Jenkins pipeline.

With this situation, modification on the shared library will not make effect on this specific issue. The webhook on Bitbucket does not have an opton to exclude

OpenShift Build qstestupdt-cd/angular-refs-notes-commits-2 from https://bitbucket.com/scm/qstestupdt/qstestupdt-angular.git
Checking out git https://bitbucket.com/scm/qstestupdt/qstestupdt-angular.git into /var/lib/jenkins/jobs/qstestupdt-cd/jobs/qstestupdt-cd-angular-refs-notes-commits/workspace@script/0617ad929e797869ec8221cd15bab14df13335d20944031ecd9cd88fbcb53b55 to read Jenkinsfile
The recommended git tool is: NONE
using credential qstestupdt-cd-cd-user-with-password
 > git rev-parse --resolve-git-dir /var/lib/jenkins/jobs/qstestupdt-cd/jobs/qstestupdt-cd-angular-refs-notes-commits/workspace@script/0617ad929e797869ec8221cd15bab14df13335d20944031ecd9cd88fbcb53b55/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://bitbucket.com/scm/qstestupdt/qstestupdt-angular.git # timeout=10
Fetching upstream changes from https://bitbucket.com/scm/qstestupdt/qstestupdt-angular.git
 > git --version # timeout=10
 > git --version # 'git version 2.39.3'
using GIT_ASKPASS to set credentials qstestupdt-cd-cd-user-with-password
 > git fetch --tags --force --progress -- https://bitbucket.com/scm/qstestupdt/qstestupdt-angular.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/refs/notes/commits^{commit} # timeout=10
 > git rev-parse refs/notes/commits^{commit} # timeout=10
 > git rev-parse refs/notes/commits^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
ERROR: Maximum checkout retry attempts reached, aborting
Finished: FAILURE
ElfenB commented 1 month ago

@braisvq1996, thank you for the feedback! I'll cancel the PR. Do you have a different idea how to do this? Perhaps in the webhook proxy (so 1 step earlier in the process)?

braisvq1996 commented 1 month ago

Yes @ElfenB , the only way would be on the webhook proxy in ods-core repository, but I do not think the feature to filter out certain commits is available.