-
Notifications
You must be signed in to change notification settings - Fork 1
/
vsts.ts
31 lines (27 loc) · 1021 Bytes
/
vsts.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// https://docs.microsoft.com/en-us/vsts/pipelines/build/variables
// The docs indicate that SYSTEM_PULLREQUEST_SOURCEBRANCH and SYSTEM_PULLREQUEST_TARGETBRANCH are in the long format (e.g `refs/heads/master`) however tests show they are both in the short format (e.g. `master`)
import type { DetectProvider } from "../types.ts";
const vstsProvider: DetectProvider = {
detect(env) {
return Boolean(env.BUILD_BUILDURI);
},
// deno-lint-ignore require-await
async configuration(env) {
const pr = env.SYSTEM_PULLREQUEST_PULLREQUESTID;
const isPr = Boolean(pr);
return {
name: "Visual Studio Team Services",
service: "vsts",
commit: env.BUILD_SOURCEVERSION,
build: env.BUILD_BUILDNUMBER,
branch: isPr
? env.SYSTEM_PULLREQUEST_TARGETBRANCH
: env.BUILD_SOURCEBRANCHNAME,
pr,
isPr,
prBranch: isPr ? env.SYSTEM_PULLREQUEST_SOURCEBRANCH : undefined,
root: env.BUILD_REPOSITORY_LOCALPATH,
};
},
};
export default vstsProvider;