Skip to content

Commit 251ce86

Browse files
committed
Retrieve exclusion list from environment variable
1 parent e9be72b commit 251ce86

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/cml.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,13 @@ class CML {
408408
}
409409

410410
async startRunner(opts = {}) {
411-
return await this.getDriver().startRunner(opts);
411+
const env = {};
412+
const sensitive =
413+
['CML_RUNNER_SENSITIVE_ENV'] +
414+
process.env.CML_RUNNER_SENSITIVE_ENV.split(':');
415+
for (const variable in process.env)
416+
if (!sensitive.includes(variable)) env[variable] = process.env[variable];
417+
return await this.getDriver().startRunner({ ...opts, env });
412418
}
413419

414420
async registerRunner(opts = {}) {

src/drivers/bitbucket_cloud.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class BitbucketCloud {
124124

125125
async startRunner(opts) {
126126
const { projectPath } = this;
127-
const { workdir, name, labels } = opts;
127+
const { workdir, name, labels, env } = opts;
128128

129129
winston.warn(
130130
`Bitbucket runner is working under /tmp folder and not under ${workdir} as expected`
@@ -155,7 +155,7 @@ class BitbucketCloud {
155155
${gpu ? '--runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all' : ''} \
156156
docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner:1`;
157157

158-
return spawn(command, { shell: true });
158+
return spawn(command, { shell: true, env });
159159
} catch (err) {
160160
throw new Error(`Failed preparing runner: ${err.message}`);
161161
}

src/drivers/github.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class Github {
249249
}
250250

251251
async startRunner(opts) {
252-
const { workdir, single, name, labels } = opts;
252+
const { workdir, single, name, labels, env } = opts;
253253

254254
try {
255255
const runnerCfg = resolve(workdir, '.runner');
@@ -285,7 +285,7 @@ class Github {
285285

286286
return spawn(resolve(workdir, 'run.sh'), {
287287
shell: true,
288-
env: {}
288+
env
289289
});
290290
} catch (err) {
291291
throw new Error(`Failed preparing GitHub runner: ${err.message}`);

src/drivers/gitlab.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ class Gitlab {
176176
single,
177177
labels,
178178
name,
179-
dockerVolumes = []
179+
dockerVolumes = [],
180+
env
180181
} = opts;
181182

182183
const gpu = await gpuPresent();
@@ -210,7 +211,7 @@ class Gitlab {
210211
${dockerVolumesTpl} \
211212
${single ? '--max-builds 1' : ''}`;
212213

213-
return spawn(command, { shell: true, env: {} });
214+
return spawn(command, { shell: true, env });
214215
} catch (err) {
215216
if (err.message === 'Forbidden')
216217
err.message +=

0 commit comments

Comments
 (0)