Skip to content

Bugfix --preserve-environment and add --preserve-entire-environment. #199

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

Merged
merged 1 commit into from
Sep 29, 2016
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
2 changes: 2 additions & 0 deletions cwltool/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def run(self, dry_run=False, pull_image=True, rm_container=True,
if not os.path.exists(self.tmpdir):
os.makedirs(self.tmpdir)
vars_to_preserve = kwargs.get("preserve_environment")
if kwargs.get("preserve_entire_environment"):
vars_to_preserve = os.environ
if vars_to_preserve is not None:
for key, value in os.environ.items():
if key in vars_to_preserve and key not in env:
Expand Down
13 changes: 9 additions & 4 deletions cwltool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,17 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
help="Do not execute jobs in a Docker container, even when specified by the CommandLineTool",
dest="use_container")

parser.add_argument("--preserve-environment", type=Text, nargs='+',
help="Preserve specified environment variables when running CommandLineTools",
metavar=("VAR1,VAR2"),
default=("PATH",),
parser.add_argument("--preserve-environment", type=Text, action="append",
help="Preserve specific environment variable when running CommandLineTools. May be provided multiple times.",
metavar="ENVVAR",
default=["PATH"],
dest="preserve_environment")

parser.add_argument("--preserve-entire-environment", action="store_true",
help="Preserve entire parent environment when running CommandLineTools.",
default=False,
dest="preserve_entire_environment")

exgroup = parser.add_mutually_exclusive_group()
exgroup.add_argument("--rm-container", action="store_true", default=True,
help="Delete Docker container used by jobs after they exit (default)",
Expand Down