Skip to content

Commit 42079f4

Browse files
committed
add logs to buildkite
1 parent 9a73e3e commit 42079f4

File tree

1 file changed

+47
-16
lines changed
  • packages/bundler-plugin-core/src/utils/providers

1 file changed

+47
-16
lines changed

packages/bundler-plugin-core/src/utils/providers/Buildkite.ts

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,63 @@ export function detect(envs: ProviderEnvs): boolean {
1111
return Boolean(envs?.BUILDKITE);
1212
}
1313

14-
function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] {
14+
function _getBuild(
15+
inputs: ProviderUtilInputs,
16+
output: Output,
17+
): ProviderServiceParams["build"] {
1518
const { args, envs } = inputs;
1619
if (args?.build && args.build !== "") {
20+
debug(`Using build: ${args.build}`, { enabled: output.debug });
1721
return args.build;
1822
}
19-
return envs?.BUILDKITE_BUILD_NUMBER ?? null;
23+
const build = envs?.BUILDKITE_BUILD_NUMBER ?? null;
24+
debug(`Using build: ${build}`, { enabled: output.debug });
25+
return build;
2026
}
2127

2228
function _getBuildURL(
2329
inputs: ProviderUtilInputs,
30+
output: Output,
2431
): ProviderServiceParams["buildURL"] {
25-
return inputs.envs?.BUILDKITE_BUILD_URL ?? null;
32+
const { envs } = inputs;
33+
const buildURL = envs?.BUILDKITE_BUILD_URL ?? null;
34+
debug(`Using buildURL: ${buildURL}`, { enabled: output.debug });
35+
return buildURL;
2636
}
2737

2838
function _getBranch(
2939
inputs: ProviderUtilInputs,
40+
output: Output,
3041
): ProviderServiceParams["branch"] {
3142
const { args, envs } = inputs;
3243
if (args?.branch && args.branch !== "") {
44+
debug(`Using branch: ${args.branch}`, { enabled: output.debug });
3345
return args.branch;
3446
}
35-
return envs?.BUILDKITE_BRANCH ?? null;
47+
48+
const branch = envs?.BUILDKITE_BRANCH ?? null;
49+
debug(`Using branch: ${branch}`, { enabled: output.debug });
50+
return branch;
3651
}
3752

38-
function _getJob(envs: ProviderEnvs): ProviderServiceParams["job"] {
39-
return envs?.BUILDKITE_JOB_ID ?? null;
53+
function _getJob(
54+
inputs: ProviderUtilInputs,
55+
output: Output,
56+
): ProviderServiceParams["job"] {
57+
const { envs } = inputs;
58+
const job = envs?.BUILDKITE_JOB_ID ?? null;
59+
debug(`Using job: ${job}`, { enabled: output.debug });
60+
return job;
4061
}
4162

42-
function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] {
63+
function _getPR(
64+
inputs: ProviderUtilInputs,
65+
output: Output,
66+
): ProviderServiceParams["pr"] {
4367
const { args } = inputs;
44-
return args?.pr ?? null;
68+
const pr = args?.pr ?? null;
69+
debug(`Using pr: ${pr}`, { enabled: output.debug });
70+
return pr;
4571
}
4672

4773
export function _getService(): ProviderServiceParams["service"] {
@@ -68,13 +94,18 @@ function _getSHA(
6894
return envs?.BUILDKITE_COMMIT ?? null;
6995
}
7096

71-
function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] {
97+
function _getSlug(
98+
inputs: ProviderUtilInputs,
99+
output: Output,
100+
): ProviderServiceParams["slug"] {
72101
const { args, envs } = inputs;
73-
return setSlug(
102+
const slug = setSlug(
74103
args?.slug,
75104
envs?.BUILDKITE_ORGANIZATION_SLUG,
76105
envs?.BUILDKITE_PIPELINE_SLUG,
77106
);
107+
debug(`Using slug: ${slug}`, { enabled: output.debug });
108+
return slug;
78109
}
79110

80111
// eslint-disable-next-line @typescript-eslint/require-await
@@ -83,14 +114,14 @@ export async function getServiceParams(
83114
output: Output,
84115
): Promise<ProviderServiceParams> {
85116
return {
86-
branch: _getBranch(inputs),
87-
build: _getBuild(inputs),
88-
buildURL: _getBuildURL(inputs),
117+
branch: _getBranch(inputs, output),
118+
build: _getBuild(inputs, output),
119+
buildURL: _getBuildURL(inputs, output),
89120
commit: _getSHA(inputs, output),
90-
job: _getJob(inputs.envs),
91-
pr: _getPR(inputs),
121+
job: _getJob(inputs, output),
122+
pr: _getPR(inputs, output),
92123
service: _getService(),
93-
slug: _getSlug(inputs),
124+
slug: _getSlug(inputs, output),
94125
};
95126
}
96127

0 commit comments

Comments
 (0)