Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exclusion list for environment variables #802

Merged
merged 16 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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 @@ -408,7 +408,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 @@ -124,7 +124,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 @@ -155,7 +155,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
5 changes: 3 additions & 2 deletions src/drivers/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class Github {
}

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

try {
const runnerCfg = resolve(workdir, '.runner');
Expand Down Expand Up @@ -284,7 +284,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 @@ -176,7 +176,8 @@ class Gitlab {
single,
labels,
name,
dockerVolumes = []
dockerVolumes = [],
env
} = opts;

const gpu = await gpuPresent();
Expand Down Expand Up @@ -210,7 +211,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