I am not very familiar with CodeBuild, but looking at the doc:
CODEBUILD_WEBHOOK_TRIGGER : Shows the webhook event that triggered the build. This variable is available only for builds triggered by a webhook. The value is parsed from the payload sent to CodeBuild by Github, Github Enterprise, or Bitbucket. The value’s format depends on what type of event triggered the build.
For builds triggered by a pull request, it is pr/pull-request-number .
, you should have an environment variable called CODEBUILD_WEBHOOK_TRIGGER with the format pr/<pr_number> when the build is triggered from a Github Pull Request.
Extracting the pr number from this variable should do the job.
Hello, this only works when you only use Github webhooks for creation of a new PR. When you are using webhooks to build every commit the trigger and head ref contain the branch information not the PR information.
is the intended usage only to analyze the code when a new PR is opened?
Hello, this method only works when receiving a webhook for opening a new PR. When receiving webhooks for commits to a repo they do not contain any information about the PR # which encompasses the branch.
Is the intended behavior of sonarcloud to only analyze the code when a new PR is opened and not on every commit? Thanks!