def main(cmd_args): parser = OptionParser() args = parser.parse_args(cmd_args) params_file_path = get_params_file_path() params = {"USER_NAME": "", "PASSWORD": "", "JENKINS_URL": ""} if os.path.exists(params_file_path): try: params_file_path = get_params_file_path() params = imp.load_source("params", params_file_path) except ImportError as e: print(e) server_url = get_jenkins_url(args, params) username = get_username(args, params) password = get_password(args, params) jobs = get_jobs(params) config = { "server_url": server_url, "username": username, "password": password, "jobs": jobs, "params_file": get_params_file_path(), "job_name": args.job_name, } logger.info("-----------------------------") logger.info("Starting script execution") logger.info("-----------------------------") action = ArgsHandler.prepare_action(args) action.run(**config)
def test_parser_recognizes_run_actions_short_option(self): # given parser = OptionParser() # when args = parser.parse_args([ '-r', '--username', 'test_user', '--password', 'secretpass', '--server-url', 'http://mytestserver.org' ]) # then assert args.run_actions is True
def test_parser_recognizes_server_url_short_option(self): # given parser = OptionParser() # when args = parser.parse_args( [ '--list-jobs', '--job-name', 'test-job', '--username', 'test_user', '--password', 'secretpass', '-s', 'http://mytestserver.org' ] ) # then assert args.server_url == 'http://mytestserver.org'
def test_parser_recognizes_list_jobs_option(self): # given parser = OptionParser() # when args = parser.parse_args( [ '--list-jobs', '--job-name', 'test-job', '--username', 'test_user', '--password', 'secretpass', '--server-url', 'http://mytestserver.org' ] ) # then assert args.list_jobs is True