def test_get_jvm_from_extra_parameters(self): extra_params = ["-DRepour_Java=1.8.0", "not appropriate"] jvm = util.get_jvm_from_extra_parameters(extra_params) self.assertEqual("1.8.0", jvm) extra_params = ["not really", "not appropriate"] jvm_not_specified = util.get_jvm_from_extra_parameters(extra_params) self.assertEqual(None, jvm_not_specified)
async def adjust(repo_dir, extra_adjust_parameters, adjust_result): nonlocal execution_name alignment_parameters = ["-DrestMode=" + rest_mode] if suffix_prefix: alignment_parameters.append( "-DversionIncrementalSuffix=" + suffix_prefix + "-redhat" ) if brew_pull_enabled: alignment_parameters.append("-DrestBrewPullActive=true") extra_parameters, subfolder = util.get_extra_parameters(extra_adjust_parameters) jvm_version = util.get_jvm_from_extra_parameters(extra_parameters) if jvm_version: location = "/usr/lib/jvm/java-" + jvm_version + "-openjdk/bin/" logger.info("Specifying java path: " + location) else: location = "" await util.print_java_version(java_bin_dir=location) # readjust the repo_dir to run PME from the folder where the root pom.xml is located # See: PRODTASKS-361 repo_dir = os.path.join(repo_dir, subfolder) log_context_value = await util.generate_user_context() log_context_parameter = ["-DrestHeaders=" + log_context_value] util.verify_folder_exists( repo_dir, "'{}' path specified in alignment parameters doesn't exist".format( subfolder ), ) cmd = ( [location + "java", "-jar", pme_jar_path] + default_parameters + extra_parameters + repour_parameters + alignment_parameters + log_context_parameter ) logger.info( 'Executing "' + execution_name + '" using "pme" adjust provider ' + '(delegating to "process" provider). Command is "{cmd}".'.format( **locals() ) ) res = await process_provider.get_process_provider( execution_name, cmd, get_result_data=get_result_data, send_log=output_to_logs, )(repo_dir, extra_adjust_parameters, adjust_result) pme_disabled = is_pme_disabled_via_extra_parameters(extra_adjust_parameters) if pme_disabled: logger.warning("PME is disabled via extra parameters") await create_pme_result_file(repo_dir) ( override_group_id, override_artifact_id, ) = await get_extra_param_execution_root_name(extra_adjust_parameters) adjust_result["resultData"] = await get_result_data( repo_dir, extra_parameters, override_group_id, override_artifact_id ) return res
async def adjust(work_dir, extra_adjust_parameters, adjust_result): """Generate the manipulation.json file with information about aligned versions""" if not os.path.exists(init_file_path): raise Exception( "The Gradle init file '{}' does not exist - are you sure you provided the correct path in configuration?" .format(init_file_path)) alignment_parameters = ["-DrestMode=" + rest_mode] if suffix_prefix: alignment_parameters.append("-DversionIncrementalSuffix=" + suffix_prefix + "-redhat") if brew_pull_enabled: alignment_parameters.append("-DrestBrewPullActive=true") extra_parameters, subfolder = util.get_extra_parameters( extra_adjust_parameters, flags=("-t", "--target")) work_dir = os.path.join(work_dir, subfolder) util.verify_folder_exists( work_dir, "'{}' path specified in alignment parameter doesn't exist".format( subfolder), ) logger.info("Adjusting in {}".format(work_dir)) jvm_version = util.get_jvm_from_extra_parameters(extra_parameters) if jvm_version: location = "/usr/lib/jvm/java-" + jvm_version + "-openjdk/bin/" logger.info("Specifying java path: " + location) else: location = "" await util.print_java_version(java_bin_dir=location) target_and_init = [ "--target=" + work_dir, "--init-script=" + init_file_path ] if not gradlew_path_present(work_dir): target_and_init.append("-l=" + default_gradle_path) cmd = ([location + "java", "-jar", gme_jar_path] + default_parameters + target_and_init + extra_parameters + repour_parameters + alignment_parameters) result = await process_provider.get_process_provider( EXECUTION_NAME, cmd, get_result_data=get_result_data, send_log=True, )(work_dir, extra_adjust_parameters, adjust_result) if gme_repos_dot_gradle_present(work_dir): logger.info("Explicitly adding file {}".format( os.path.join(work_dir, "gradle", "gme-repos.gradle"))) await git.add_file(work_dir, os.path.join("gradle", "gme-repos.gradle"), force=True) ( override_group_id, override_artifact_id, ) = await pme_provider.get_extra_param_execution_root_name( extra_adjust_parameters) adjust_result["adjustType"] = result["adjustType"] adjust_result["resultData"] = await get_result_data( work_dir, extra_parameters, group_id=override_group_id, artifact_id=override_artifact_id, ) return result
async def adjust(repo_dir, extra_adjust_parameters, adjust_result): nonlocal execution_name alignment_parameters = ["-DrestMode=" + rest_mode] if suffix_prefix: alignment_parameters.append("-DversionIncrementalSuffix=" + suffix_prefix + "-redhat") if brew_pull_enabled: alignment_parameters.append("-DrestBrewPullActive=true") suffix_prefix_no_temporary = util.strip_temporary_from_prefix( suffix_prefix) # NCLSUP-669: specify the versionSuffixAlternatives if we prefer persistent build alignment for the temp build # and the suffix_prefix without the temporary string is not empty (e.g for managedsvc) if temp_prefer_persistent_enabled and suffix_prefix_no_temporary: alignment_parameters.append("-DversionSuffixAlternatives=redhat," + suffix_prefix_no_temporary + "-redhat") extra_parameters, subfolder_or_file = util.get_extra_parameters( extra_adjust_parameters) # [NCLSUP-626] for PME, we re-add the --file option inside extra_parameters # since the user can specify any xml file to align, not just the specific file name 'pom.xml' if subfolder_or_file: extra_parameters.append("--file=" + subfolder_or_file) jvm_version = util.get_jvm_from_extra_parameters(extra_parameters) if jvm_version: location = "/usr/lib/jvm/java-" + jvm_version + "-openjdk/bin/" logger.info("Specifying java path: " + location) else: location = "" await util.print_java_version(java_bin_dir=location) # readjust the repo_dir to run PME from the folder where the root pom.xml is located # See: PRODTASKS-361 log_context_value = await util.generate_user_context() log_context_parameter = ["-DrestHeaders=" + log_context_value] if not os.path.exists(os.path.join(repo_dir, subfolder_or_file)): logger.error( "'{}' path specified in alignment parameters doesn't exist". format(subfolder_or_file)) cmd = ([location + "java", "-jar", pme_jar_path] + default_parameters + extra_parameters + repour_parameters + alignment_parameters + log_context_parameter) logger.info( 'Executing "' + execution_name + '" using "pme" adjust provider ' + '(delegating to "process" provider). Command is "{cmd}".'.format( **locals())) folder_where_results_are = os.path.join(repo_dir, subfolder_or_file) # if folder_where_results_are is actually a file, use the parent folder instead if os.path.isfile(folder_where_results_are): folder_where_results_are = str( Path(folder_where_results_are).parent) res = await process_provider.get_process_provider( execution_name, cmd, get_result_data=get_result_data, send_log=output_to_logs, )( repo_dir, extra_adjust_parameters, adjust_result, dir_results=folder_where_results_are, ) pme_disabled = is_pme_disabled_via_extra_parameters( extra_adjust_parameters) if pme_disabled: logger.warning("PME is disabled via extra parameters") await create_pme_result_file(repo_dir) ( override_group_id, override_artifact_id, ) = await get_extra_param_execution_root_name(extra_adjust_parameters) adjust_result["resultData"] = await get_result_data( folder_where_results_are, extra_parameters, override_group_id, override_artifact_id, ) return res