def __enter__(self): try: start_go_server(self.gocd_version, self.gocd_download_version_string) configurator = GoCdConfigurator(HostRestClient('localhost:8153')) pipeline = configurator \ .ensure_pipeline_group("P.Group") \ .ensure_replacement_of_pipeline("more-options") \ .set_timer("0 15 22 * * ?") \ .set_git_material(GitMaterial("https://github.com/SpringerSBM/gomatic.git", material_name="some-material-name", polling=False)) \ .ensure_environment_variables({'JAVA_HOME': '/opt/java/jdk-1.7'}) \ .ensure_parameters({'environment': 'qa'}) stage = pipeline.ensure_stage("earlyStage") job = stage.ensure_job("earlyWorm").ensure_artifacts({ Artifact.get_build_artifact("scripts/*", "files"), Artifact.get_build_artifact("target/universal/myapp*.zip", "artifacts"), Artifact.get_test_artifact("from", "to") }).set_runs_on_all_agents() job.add_task(ExecTask(['ls'])) configurator.save_updated_config(save_config_locally=True) return GoCdConfigurator(HostRestClient('localhost:8153')) except: # Swallow exception if __exit__ returns a True value if self.__exit__(*sys.exc_info()): pass else: raise
def __init__(self, args, hop_config): self.args = args self.hop_config = hop_config self.plans = {} self.configurator = GoCdConfigurator( SecureHostRestClient(host=args.host or hop_config.host, username=args.user or 'admin', password=args.password or hop_config.admin_password, ssl=False))
def execute(args, **kwargs): # pylint: disable=unused-argument hop_config = kwargs['hop_config'] configurator = GoCdConfigurator( SecureHostRestClient(host=args.host or hop_config.configure_url, username=args.user or 'admin', password=args.password or hop_config.admin_password, ssl=True, verify_ssl=False)) configure(configurator, apps=_find_all_apps(args.context))
def dummy_ensure_pipeline(script): """ Run ``script`` against a dummy GoCdConfigurator set to export the config-after.xml. """ configurator = GoCdConfigurator(empty_config()) with open('test-config.yml') as test_config_file: test_config = yaml.safe_load(test_config_file) config = TestConfigMerger(test_config) script = imp.load_source('pipeline_script', script) script.install_pipelines(configurator, config) configurator.save_updated_config(save_config_locally=True, dry_run=True)
def cli( # pylint: disable=missing-docstring save_config_locally, dry_run, variable_files, env_variable_files, env_deploy_variable_files, cmd_line_vars): config = utils.ConfigMerger(variable_files, env_variable_files, env_deploy_variable_files, cmd_line_vars) # Create the pipeline configurator = GoCdConfigurator( HostRestClient(config['gocd_url'], config['gocd_username'], config['gocd_password'], ssl=True)) return_val = install_pipelines(configurator, config) configurator.save_updated_config( save_config_locally=save_config_locally, dry_run=dry_run) return return_val