Skip to content

Commit 36da045

Browse files
authored
Retrieve exclusion list from environment variable
1 parent a8cc364 commit 36da045

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
@@ -402,7 +402,13 @@ class CML {
402402
}
403403

404404
async startRunner(opts = {}) {
405-
return await this.getDriver().startRunner(opts);
405+
const env = {};
406+
const sensitive =
407+
['CML_RUNNER_SENSITIVE_ENV'] +
408+
process.env.CML_RUNNER_SENSITIVE_ENV.split(':');
409+
for (const variable in process.env)
410+
if (!sensitive.includes(variable)) env[variable] = process.env[variable];
411+
return await this.getDriver().startRunner({ ...opts, env });
406412
}
407413

408414
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
@@ -250,7 +250,7 @@ class Github {
250250
}
251251

252252
async startRunner(opts) {
253-
const { workdir, single, name, labels } = opts;
253+
const { workdir, single, name, labels, env } = opts;
254254

255255
try {
256256
const runnerCfg = resolve(workdir, '.runner');
@@ -286,7 +286,7 @@ class Github {
286286

287287
return spawn(resolve(workdir, 'run.sh'), {
288288
shell: true,
289-
env: {}
289+
env
290290
});
291291
} catch (err) {
292292
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)