diff --git a/cpt/packager.py b/cpt/packager.py index 38a0aa24..ac54f2c7 100644 --- a/cpt/packager.py +++ b/cpt/packager.py @@ -91,6 +91,7 @@ def __init__(self, username=None, channel=None, runner=None, docker_image_skip_pull=False, docker_entry_script=None, docker_32_images=None, + docker_args=None, pip_install=None, build_policy=None, always_update_conan_in_docker=False, @@ -249,6 +250,12 @@ def __init__(self, username=None, channel=None, runner=None, else: self.docker_32_images = os.getenv("CONAN_DOCKER_32_IMAGES", False) + docker_args = docker_args or split_colon_env("CPT_DOCKER_ARGS") + + if docker_args is None: + docker_args = [] + self.docker_args = docker_args + self.curpage = curpage or os.getenv("CONAN_CURRENT_PAGE", 1) self.total_pages = total_pages or os.getenv("CONAN_TOTAL_PAGES", 1) @@ -537,7 +544,8 @@ def run_builds(self, curpage=None, total_pages=None, base_profile_name=None): config_url=self.config_url) r.run(pull_image=not pulled_docker_images[docker_image], - docker_entry_script=self.docker_entry_script) + docker_entry_script=self.docker_entry_script, + docker_args=self.docker_args) pulled_docker_images[docker_image] = True def _get_docker_image(self, build): diff --git a/cpt/runner.py b/cpt/runner.py index 924359a6..27dfd6f7 100644 --- a/cpt/runner.py +++ b/cpt/runner.py @@ -160,10 +160,11 @@ def _pip_update_conan_command(self): command = " && ".join(commands) return command - def run(self, pull_image=True, docker_entry_script=None): + def run(self, pull_image=True, docker_entry_script=None, docker_args=None): envs = self.get_env_vars() env_vars_text = " ".join(['-e %s="%s"' % (key, value) for key, value in envs.items() if value]) + docker_args_str = " ".join(docker_args) # Run the build if pull_image: @@ -201,11 +202,12 @@ def run(self, pull_image=True, docker_entry_script=None): else: update_command = "" - command = ('%s docker run --rm -v "%s:%s/project" %s %s %s %s ' + command = ('%s docker run --rm -v "%s:%s/project" %s %s %s %s %s ' '"%s cd project && ' '%s run_create_in_docker "' % (self._sudo_docker_command, os.getcwd(), self._docker_conan_home, + docker_args_str, env_vars_text, self._docker_platform_param, self._docker_image, diff --git a/cpt/test/unit/packager_test.py b/cpt/test/unit/packager_test.py index f1730e36..74356ae7 100644 --- a/cpt/test/unit/packager_test.py +++ b/cpt/test/unit/packager_test.py @@ -343,6 +343,22 @@ def test_docker_env_propagated(self): self.packager.run_builds(1, 1) self.assertIn('-e CONAN_FAKE_VAR="32"', self.runner.calls[-1]) + def test_docker_args(self): + # test env + with tools.environment_append({"CPT_DOCKER_ARGS": "-m,2gb,--isolation=hyperv"}): + self.packager = ConanMultiPackager(username="lasote", + channel="mychannel", + runner=self.runner, + conan_api=self.conan_api, + gcc_versions=["5", "6"], + clang_versions=["3.9", "4.0"], + use_docker=True, + reference="zlib/1.2.11", + ci_manager=self.ci_manager) + self._add_build(1, "gcc", "5") + self.packager.run_builds(1, 1) + self.assertIn('-m 2gb --isolation=hyperv', self.runner.calls[-1]) + def test_docker_invalid(self): self.packager = ConanMultiPackager(username="lasote", channel="mychannel",