From 1f16313e65d053ed43c32eb1fd8aa0051c2892a6 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 26 Aug 2024 22:13:24 -0400 Subject: [PATCH] feat: branch support for Buddy (#366) --- README.md | 13 +------------ services/buddy.js | 4 +++- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7555cd9a..b3120935 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ the Pull Request originated. | [Bamboo](https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html) | `bamboo` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | | [Bitbucket](https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html) | `bitbucket` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | | [Bitrise](https://devcenter.bitrise.io/builds/available-environment-variables/#exposed-by-bitriseio) | `bitrise` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | -| [Buddy](https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables) | `buddy` | :white_check_mark: | [:warning:](#buddy) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | +| [Buddy](https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables) | `buddy` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | | [Buildkite](https://buildkite.com/docs/builds/environment-variables) | `buildkite` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | [CircleCI](https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables) | `circleci` | :white_check_mark: | [:warning:](#circleci) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | | [Cirrus CI](https://cirrus-ci.org/guide/writing-tasks/#environment-variables) | `cirrus` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | @@ -164,17 +164,6 @@ detached `HEAD` to determine the branch from which the detached `HEAD` was creat In the rare case where there is multiple remote branches with the same `HEAD` as the local detached `HEAD`, `env-ci` will arbitrarily pick the first one. This can lead to an inaccurate `branch` value in such circumstances. -### Buddy - -For builds triggered when [a Pull Request is opened/updated](https://buddy.works/knowledge/deployments/pull-requests), -Buddy doesn't provide an environment variable indicating the branch from which the Pull Request originated nor the -target branch. It also build from a branch named `pull/` so the target branch cannot be determined with -a `git` command. -Therefore, in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` and `prBranch` -properties. - -See [feature request](https://forum.buddy.works/t/determine-pull-request-branch-with-environment-variable/911). - ### CircleCI For builds triggered when a Pull Request is opened/updated, CircleCI doesn't provide an environment variable indicating diff --git a/services/buddy.js b/services/buddy.js index 35183176..10395d9a 100644 --- a/services/buddy.js +++ b/services/buddy.js @@ -17,7 +17,9 @@ export default { tag: env.BUDDY_EXECUTION_TAG, build: env.BUDDY_EXECUTION_ID, buildUrl: env.BUDDY_EXECUTION_URL, - branch: isPr ? undefined : env.BUDDY_EXECUTION_BRANCH, + branch: isPr + ? env.BUDDY_EXECUTION_PULL_REQUEST_HEAD_BRANCH + : env.BUDDY_EXECUTION_BRANCH, pr, isPr, slug: env.BUDDY_REPO_SLUG,