Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,14 @@ class CML {
}

async startRunner(opts = {}) {
return await this.getDriver().startRunner(opts);
const env = {};
const sensitive = [
'_CML_RUNNER_SENSITIVE_ENV',
...process.env._CML_RUNNER_SENSITIVE_ENV.split(':')
];
for (const variable in process.env)
if (!sensitive.includes(variable)) env[variable] = process.env[variable];
return await this.getDriver().startRunner({ ...opts, env });
}

async registerRunner(opts = {}) {
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/bitbucket_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class BitbucketCloud {

async startRunner(opts) {
const { projectPath } = this;
const { workdir, name, labels } = opts;
const { workdir, name, labels, env } = opts;

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

return spawn(command, { shell: true });
return spawn(command, { shell: true, env });
} catch (err) {
throw new Error(`Failed preparing runner: ${err.message}`);
}
Expand Down
9 changes: 7 additions & 2 deletions src/drivers/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@ class Github {
}

async startRunner(opts) {
const { workdir, single, name, labels } = opts;
const { workdir, single, name, labels, env } = opts;

this.warn(
'cloud credentials are no longer available on self-hosted runner steps; please use step.env and secrets instead'
);

try {
const runnerCfg = resolve(workdir, '.runner');
Expand Down Expand Up @@ -295,7 +299,8 @@ class Github {
);

return spawn(resolve(workdir, 'run.sh'), {
shell: true
shell: true,
env
});
} catch (err) {
throw new Error(`Failed preparing GitHub runner: ${err.message}`);
Expand Down
5 changes: 3 additions & 2 deletions src/drivers/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ class Gitlab {
single,
labels,
name,
dockerVolumes = []
dockerVolumes = [],
env
} = opts;

const gpu = await gpuPresent();
Expand Down Expand Up @@ -217,7 +218,7 @@ class Gitlab {
${dockerVolumesTpl} \
${single ? '--max-builds 1' : ''}`;

return spawn(command, { shell: true });
return spawn(command, { shell: true, env });
} catch (err) {
if (err.message === 'Forbidden')
err.message +=
Expand Down