0
# Provider Detection
1
2
CI/CD and hosting provider identification with support for 50+ popular services including GitHub Actions, GitLab CI, Vercel, Netlify, and many others.
3
4
## Capabilities
5
6
### Provider Name
7
8
Current provider name as detected from environment variables.
9
10
```typescript { .api }
11
/**
12
* Current CI/CD or hosting provider name
13
* Empty string if no provider is detected
14
*/
15
const provider: ProviderName;
16
17
type ProviderName =
18
| "" // Unknown/no provider
19
| "appveyor" // AppVeyor
20
| "aws_amplify" // AWS Amplify
21
| "azure_pipelines" // Azure Pipelines
22
| "azure_static" // Azure Static Web Apps
23
| "appcircle" // Appcircle
24
| "bamboo" // Atlassian Bamboo
25
| "bitbucket" // Bitbucket Pipelines
26
| "bitrise" // Bitrise
27
| "buddy" // Buddy
28
| "buildkite" // Buildkite
29
| "circle" // CircleCI
30
| "cirrus" // Cirrus CI
31
| "cloudflare_pages" // Cloudflare Pages
32
| "cloudflare_workers" // Cloudflare Workers
33
| "codebuild" // AWS CodeBuild
34
| "codefresh" // Codefresh
35
| "drone" // Drone CI
36
| "dsari" // DSARI
37
| "github_actions" // GitHub Actions
38
| "gitlab" // GitLab CI
39
| "gocd" // GoCD
40
| "layerci" // LayerCI
41
| "hudson" // Hudson CI
42
| "jenkins" // Jenkins
43
| "magnum" // Magnum CI
44
| "netlify" // Netlify
45
| "nevercode" // Nevercode
46
| "render" // Render
47
| "sail" // Sail CI
48
| "semaphore" // Semaphore CI
49
| "screwdriver" // Screwdriver
50
| "shippable" // Shippable
51
| "solano" // Solano CI
52
| "strider" // Strider CD
53
| "teamcity" // TeamCity
54
| "travis" // Travis CI
55
| "vercel" // Vercel
56
| "appcenter" // App Center
57
| "codesandbox" // CodeSandbox
58
| "stackblitz" // StackBlitz
59
| "stormkit" // Stormkit
60
| "cleavr" // Cleavr
61
| "zeabur" // Zeabur
62
| "codesphere" // Codesphere
63
| "railway" // Railway
64
| "deno-deploy" // Deno Deploy
65
| "firebase_app_hosting"; // Firebase App Hosting
66
```
67
68
**Usage Examples:**
69
70
```typescript
71
import { provider } from "std-env";
72
73
console.log(`Current provider: ${provider}`);
74
75
// Provider-specific logic
76
switch (provider) {
77
case "github_actions":
78
console.log("Running in GitHub Actions");
79
// Use GitHub-specific environment variables
80
const runId = process.env.GITHUB_RUN_ID;
81
break;
82
83
case "gitlab":
84
console.log("Running in GitLab CI");
85
// Use GitLab-specific features
86
const jobId = process.env.CI_JOB_ID;
87
break;
88
89
case "vercel":
90
console.log("Running on Vercel");
91
// Use Vercel-specific environment
92
const deploymentUrl = process.env.VERCEL_URL;
93
break;
94
95
case "netlify":
96
console.log("Running on Netlify");
97
// Use Netlify-specific features
98
const deployId = process.env.DEPLOY_ID;
99
break;
100
101
default:
102
if (provider) {
103
console.log(`Running on ${provider}`);
104
} else {
105
console.log("No provider detected");
106
}
107
}
108
```
109
110
### Provider Information
111
112
Detailed provider information including CI status and metadata.
113
114
```typescript { .api }
115
/**
116
* Current provider information with metadata
117
* Contains provider name, CI status, and additional properties
118
*/
119
const providerInfo: ProviderInfo;
120
121
interface ProviderInfo {
122
/** Provider name */
123
name: ProviderName;
124
/** Whether this is a CI environment (optional, defaults to true for most CI providers) */
125
ci?: boolean;
126
/** Additional provider-specific metadata */
127
[meta: string]: any;
128
}
129
```
130
131
**Usage Examples:**
132
133
```typescript
134
import { providerInfo } from "std-env";
135
136
console.log(`Provider: ${providerInfo.name}`);
137
console.log(`Is CI: ${providerInfo.ci}`);
138
139
// Check if it's a CI provider
140
if (providerInfo.ci) {
141
console.log("Running in CI environment");
142
// Disable interactive features
143
// Enable CI-specific logging
144
} else if (providerInfo.name) {
145
console.log("Running on hosting platform");
146
// Platform-specific optimizations
147
}
148
149
// Access additional metadata
150
console.log("Provider info:", JSON.stringify(providerInfo, null, 2));
151
```
152
153
## Provider Detection Logic
154
155
Provider detection works by checking specific environment variables that each provider sets:
156
157
### Major CI/CD Providers
158
159
```typescript
160
// Examples of environment variables checked for each provider:
161
162
// GitHub Actions
163
if (process.env.GITHUB_ACTIONS) {
164
// Detected as "github_actions"
165
}
166
167
// GitLab CI
168
if (process.env.GITLAB_CI || process.env.CI_MERGE_REQUEST_ID) {
169
// Detected as "gitlab"
170
}
171
172
// CircleCI
173
if (process.env.CIRCLECI) {
174
// Detected as "circle"
175
}
176
177
// Travis CI
178
if (process.env.TRAVIS) {
179
// Detected as "travis"
180
}
181
182
// Jenkins
183
if (process.env.JENKINS_URL) {
184
// Detected as "jenkins"
185
}
186
```
187
188
### Hosting and Deployment Platforms
189
190
```typescript
191
// Vercel
192
if (process.env.NOW_BUILDER || process.env.VERCEL || process.env.VERCEL_ENV) {
193
// Detected as "vercel"
194
// Note: ci: false for Vercel (hosting platform, not CI)
195
}
196
197
// Netlify
198
if (process.env.NETLIFY) {
199
// Detected as "netlify"
200
// Note: ci: false for Netlify (hosting platform, not CI)
201
}
202
203
// Railway
204
if (process.env.RAILWAY_PROJECT_ID || process.env.RAILWAY_SERVICE_ID) {
205
// Detected as "railway"
206
}
207
208
// Cloudflare Pages
209
if (process.env.CF_PAGES) {
210
// Detected as "cloudflare_pages"
211
}
212
```
213
214
### Special Detection Cases
215
216
```typescript
217
// StackBlitz - Special detection for webcontainer
218
if (process.env.SHELL === "/bin/jsh" && process.versions?.webcontainer) {
219
// Detected as "stackblitz" with ci: false
220
}
221
222
// CodeSandbox
223
if (process.env.CODESANDBOX_SSE || process.env.CODESANDBOX_HOST) {
224
// Detected as "codesandbox" with ci: false
225
}
226
```
227
228
## Provider-Specific Usage Patterns
229
230
### CI/CD Integration
231
232
```typescript
233
import { provider, providerInfo, isCI } from "std-env";
234
235
// CI-specific behavior
236
if (isCI) {
237
switch (provider) {
238
case "github_actions":
239
// Set GitHub Actions outputs
240
console.log(`::set-output name=result::success`);
241
break;
242
243
case "gitlab":
244
// Use GitLab CI artifacts
245
console.log("Saving artifacts to GitLab");
246
break;
247
248
case "jenkins":
249
// Use Jenkins environment
250
const buildNumber = process.env.BUILD_NUMBER;
251
break;
252
}
253
}
254
```
255
256
### Deployment Platform Integration
257
258
```typescript
259
import { provider } from "std-env";
260
261
// Platform-specific deployment logic
262
switch (provider) {
263
case "vercel":
264
// Vercel-specific optimizations
265
console.log(`Deploy URL: ${process.env.VERCEL_URL}`);
266
break;
267
268
case "netlify":
269
// Netlify-specific features
270
console.log(`Deploy ID: ${process.env.DEPLOY_ID}`);
271
break;
272
273
case "railway":
274
// Railway-specific configuration
275
console.log(`Service: ${process.env.RAILWAY_SERVICE_NAME}`);
276
break;
277
}
278
```
279
280
### Development Environment Detection
281
282
```typescript
283
import { provider, providerInfo } from "std-env";
284
285
// Development platform detection
286
const isDevelopmentPlatform = provider && !providerInfo.ci;
287
288
if (isDevelopmentPlatform) {
289
switch (provider) {
290
case "codesandbox":
291
console.log("Running in CodeSandbox");
292
// Enable CodeSandbox-specific features
293
break;
294
295
case "stackblitz":
296
console.log("Running in StackBlitz");
297
// Enable StackBlitz-specific features
298
break;
299
}
300
}
301
```