You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-19Lines changed: 52 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,9 @@ if (isCI) {
75
75
76
76
**Note**: Some variables can be detected only on certain CI services. See [Supported CI](#supported-ci).
77
77
78
-
**Note**: The `pr` and `prBranch` properties are only available for builds triggered when a Pull Request is opened/updated and not on builds triggered by a push on a branch even if that branch happens to be the branch from which the Pull Request originated.
78
+
**Note**: The `pr` and `prBranch` properties are only available for builds triggered when a Pull Request is
79
+
opened/updated and not on builds triggered by a push on a branch even if that branch happens to be the branch from which
**Note**: Unsupported properties will always be `undefined`. For example if a Ci services doesn't support triggering builds when a Pull Request is opened/updated, `isPr` will be `undefined`.
120
+
**Note**: Unsupported properties will always be `undefined`. For example if a Ci services doesn't support triggering
121
+
builds when a Pull Request is opened/updated, `isPr` will be `undefined`.
118
122
119
-
**Note**: If none of the above CI services is detected, `commit` and `branch` are determined based on the local Git repository, and `isCi` is determined based on the `CI` environment variable.
123
+
**Note**: If none of the above CI services is detected, `commit` and `branch` are determined based on the local Git
124
+
repository, and `isCi` is determined based on the `CI` environment variable.
120
125
121
126
## API
122
127
@@ -138,7 +143,8 @@ The object to read environment variables from.
138
143
Type: `String`<br>
139
144
Default: `process.cwd()`
140
145
141
-
The current working directory in which to execute `git` commands used to determine the `commit` and `branch`[Result](#result) properties in case no [supported CI](#supported-ci) is detected.
146
+
The current working directory in which to execute `git` commands used to determine the `commit`
147
+
and `branch`[Result](#result) properties in case no [supported CI](#supported-ci) is detected.
142
148
143
149
### Result
144
150
@@ -150,48 +156,75 @@ Type: `Object`
150
156
151
157
### AWS CodeBuild
152
158
153
-
AWS CodeBuild doesn't provide an environment variable to determine the current Git branch being built. In addition, it clones the repository in a [detached head state](https://git-scm.com/docs/git-checkout#_detached_head) so the branch cannot be determined with `git rev-parse --abbrev-ref HEAD`.
154
-
To work around this limitation, `env-ci` look for the remote branches having the same `HEAD` as the local detached `HEAD` to determine the branch from which the detached `HEAD` was created.
155
-
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.
159
+
AWS CodeBuild doesn't provide an environment variable to determine the current Git branch being built. In addition, it
160
+
clones the repository in a [detached head state](https://git-scm.com/docs/git-checkout#_detached_head) so the branch
161
+
cannot be determined with `git rev-parse --abbrev-ref HEAD`.
162
+
To work around this limitation, `env-ci` look for the remote branches having the same `HEAD` as the local
163
+
detached `HEAD` to determine the branch from which the detached `HEAD` was created.
164
+
In the rare case where there is multiple remote branches with the same `HEAD` as the local detached `HEAD`, `env-ci`
165
+
will arbitrarily pick the first one. This can lead to an inaccurate `branch` value in such circumstances.
156
166
157
167
### Buddy
158
168
159
-
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/<PR number>` so the target branch cannot be determined with a `git` command.
160
-
Therefore in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` and `prBranch` properties.
169
+
For builds triggered when [a Pull Request is opened/updated](https://buddy.works/knowledge/deployments/pull-requests),
170
+
Buddy doesn't provide an environment variable indicating the branch from which the Pull Request originated nor the
171
+
target branch. It also build from a branch named `pull/<PR number>` so the target branch cannot be determined with
172
+
a `git` command.
173
+
Therefore, in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` and `prBranch`
174
+
properties.
161
175
162
176
See [feature request](https://forum.buddy.works/t/determine-pull-request-branch-with-environment-variable/911).
163
177
164
178
### CircleCI
165
179
166
-
For builds triggered when a Pull Request is opened/updated, CircleCI doesn't provide an environment variable indicating the target branch.
167
-
Therefore in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property. However `prBranch` will be set.
180
+
For builds triggered when a Pull Request is opened/updated, CircleCI doesn't provide an environment variable indicating
181
+
the target branch.
182
+
Therefore, in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property.
183
+
However `prBranch` will be set.
168
184
169
185
See [feature request](https://discuss.circleci.com/t/create-a-circle-target-branch-envar/10022).
170
186
171
187
### Cloudflare Pages
172
188
173
-
For builds triggered when a Pull Request is opened/updated, Cloudflare Pages will re-use the branch variable for the originating branch and not provide a target. Therefore `env-ci` will not be able to determine the `prBranch` property however `branch` will always be set.
189
+
For builds triggered when a Pull Request is opened/updated, Cloudflare Pages will re-use the branch variable for the
190
+
originating branch and not provide a target. Therefore `env-ci` will not be able to determine the `prBranch` property
191
+
however `branch` will always be set.
174
192
175
193
### Jenkins
176
194
177
-
Triggering build when a Pull Request is opened/updated is supported only via the [ghprb-plugin](https://github.com/jenkinsci/ghprb-plugin) and [gitlab-plugin](https://github.com/jenkinsci/gitlab-plugin). Therefore `env-ci` will set `isPr`, `pr` and `prBranch` and define `branch` with the Pull Request target branch only if one those plugin is used.
195
+
Triggering build when a Pull Request is opened/updated is supported only via
196
+
the [ghprb-plugin](https://github.com/jenkinsci/ghprb-plugin)
197
+
and [gitlab-plugin](https://github.com/jenkinsci/gitlab-plugin). Therefore `env-ci` will set `isPr`, `pr` and `prBranch`
198
+
and define `branch` with the Pull Request target branch only if one those plugin is used.
178
199
179
200
### Netlify
180
201
181
-
For builds triggered when a Pull Request is opened/updated, Netlify doesn't provide an environment variable indicating the target branch.
182
-
Therefore in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property. However `prBranch` will be set.
202
+
For builds triggered when a Pull Request is opened/updated, Netlify doesn't provide an environment variable indicating
203
+
the target branch.
204
+
Therefore, in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property.
205
+
However `prBranch` will be set.
183
206
184
207
See [feature request](https://answers.netlify.com/t/access-pr-target-branch-when-deploying-preview-build/32402)
185
208
186
209
### Sail
187
210
188
-
For builds triggered when a Pull Request is opened/updated, Sail doesn't provide an environment variable indicating the target branch, and the one for the current branch is set to `pull/<PR number>` independently of the the branch name from which the Pull Request originated.
189
-
Therefore in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` and `prBranch` properties.
211
+
For builds triggered when a Pull Request is opened/updated, Sail doesn't provide an environment variable indicating the
212
+
target branch, and the one for the current branch is set to `pull/<PR number>` independently of the the branch name from
213
+
which the Pull Request originated.
214
+
Therefore, in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` and `prBranch`
215
+
properties.
190
216
191
217
### Semaphore
192
218
193
-
For builds triggered when a Pull Request is opened/updated, Semaphore 1.0 doesn't provide an environment variable indicating the target branch.
194
-
Therefore in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property. However `prBranch` will be set.
219
+
For builds triggered when a Pull Request is opened/updated, Semaphore 1.0 doesn't provide an environment variable
220
+
indicating the target branch.
221
+
Therefore, in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property.
222
+
However `prBranch` will be set.
195
223
On Semaphore 2.0 the `branch` and `prBranch` properties will work as expected.
196
224
197
225
The property `tag` is only available on Semaphore 2.0.
226
+
227
+
### Screwdriver
228
+
229
+
For builds triggered when a Pull Request is opened/updated, Screwdriver sets the `env.GIT_BRANCH` as `head:pr` branch
230
+
type (Example:`origin/refs/pull/1/head:pr`) while at commit level (non PR) it does set it with the actual branch (Example: `origin/main`).
0 commit comments