def historical_data_menu(): """ This API :return: """ list_of_jobs = Common.validation_param_detail( "validation_parameter.sample", "jenkins_job_details") job_collection = list() actual_jobs = list() for job in list_of_jobs: actual_jobs.append(list_of_jobs[job]["job_name"].replace( "-<component-version>", "")) job_collection.append(list_of_jobs[job]["job_name"].replace( "<component-version>", "[0-9].[0-9]")) return render_template( "build_history_menu.html", job_collection=job_collection, actual_jobs=actual_jobs, )
def mapper_builder(self): """ This function is used to build the job mapper object and trigger the log analysis module to analyse the data on the basis of downloaded logs. :return: """ job_list = Controller.reading_input_data_from_xls( self.prop_obj.sheets_number[self.prop_obj.sheets], f"{os.path.abspath('.')}/config/{Common.get_config_value('analysis_input_file')}", ) Common.logger.info( f"[mapper_builder] Processing is happening for job {job_list}") [self.prop_obj.jobs_list.append(job) for job in job_list] jenkins_obj = JenkinsJob() for job_attributes in self.prop_obj.jobs_list: validation_data = Common.validation_param_detail( "validation_parameter.yaml", "jenkins_job_details")[job_attributes[0]] if job_attributes[1]: build_numbers = job_attributes[1].split(",") for build_number in build_numbers: with jenkins_obj: time_stamp = jenkins_obj.build_execution_time( validation_data["job_name"], build_number) self.prop_obj.job_mapper[build_number] = {} self.prop_obj.job_mapper[build_number][ "time_stamp"] = time_stamp self.prop_obj.job_mapper[build_number][ "skip_check"] = ast.literal_eval(job_attributes[2]) self.prop_obj.job_mapper[build_number][ "build_version"] = job_attributes[3] self.prop_obj.job_mapper[build_number][ "snap_no"] = job_attributes[4] else: with jenkins_obj: build_number, time_stamp = jenkins_obj.get_job_info( f"{validation_data['job_name']}") Common.logger.info( f"[mapper_builder]: Collected job information build_number" f" {build_number} and time stamp {time_stamp}") self.prop_obj.job_mapper[build_number] = {} self.prop_obj.job_mapper[build_number][ "time_stamp"] = time_stamp self.prop_obj.job_mapper[build_number][ "skip_check"] = ast.literal_eval(job_attributes[3]) self.prop_obj.job_mapper[build_number][ "build_version"] = job_attributes[4] self.prop_obj.job_mapper[build_number][ "snap_no"] = job_attributes[4] Common.logger.info( f"[mapper_builder] Attribute collected {job_attributes}") for build_number in self.prop_obj.job_mapper: Common.logger.info( f"[mapper_builder]: Log collection method called") build_file, build_url = JenkinsJob.jenkins_data_collection( validation_data["job_name"], int(build_number)) Common.logger.info( f"[mapper_builder] log collected for build {build_number} " f"and url {build_url}") self.prop_obj.job_mapper[build_number][ "build_file_name"] = build_file self.prop_obj.job_mapper[build_number]["build_url"] = build_url for build_number in self.prop_obj.job_mapper: Common.logger.info("[mapper_builder]: Job analysis called ...") self.log_analysis(build_number, validation_data) self.prop_obj.rows_no += 1
import bson from pymongo import MongoClient from utils.common import Common DB_CONFIG = Common.validation_param_detail("environment_setup.yaml", "config") def get_db_connection(db_name=None): """ :param db_name: :return: """ try: connection = MongoClient( host=DB_CONFIG["mongodb_container"], port=DB_CONFIG["mongodb_port"] )[db_name] return connection except Exception as ex: Common.logger.info(f"Failed to stabilised the DB connection: {ex}") return def extracting_build_info(job_name=None, build_number=None, component_version=None): """ :param job_name: :param build_number: :param component_version: :return: """ db = get_db_connection(db_name=DB_CONFIG["database_name"]) collections = db.files