def _jobs_status(self): self._connect() for job in self.J.keys(): # Check if this job has last build try: build = self.J[job].get_last_build() except jenkinsapi.custom_exceptions.NoBuildData: build = None if build: buildno = build.buildno # Status color status = build.get_status() if build.get_status() == "SUCCESS": status = TColors.green(status) elif build.get_status() == "FAILURE": status = TColors.red(status) else: status = TColors.yellow(status) # Color duration duration = format_last_run(build.get_duration(), color=False) # Color timestamp last_run = format_last_run(build.get_timestamp(), color=False) else: buildno = " - " status = " - " duration = " - " last_run = " - " # update results self.results.append([job, buildno, last_run, status, duration]) # Print results headers = ["Name", "no", "Last Run", "Status", "Exec Time"] print_table(self.results, headers=headers)
def _print_results(self): question = "Q> Ansible Summary status| host(s) '{}' returned '{}' sort '{}' order '{}' filter '{}'"\ .format(TColors.yellow(self.answers["host"]), TColors.yellow(len(self.results)), TColors.yellow(self.answers["sort"]), TColors.yellow(self.answers["order"]), TColors.yellow(self.answers["filter"])) headers = ["Host", "Last Run", "Play Name", "Ok", "CH", "UR", "FL", "Time(s)", "+Tag", "-Tag", "User"] print_table(self.results, headers=headers, question=question)
def _print_results(self): question = "Q> Ansbile failures | host(s) '{}' returned '{}' limit '{}' sort '{}' order '{}' filter '{}'"\ .format(TColors.yellow(self.answers["host"]), TColors.yellow(len(self.results)), TColors.yellow(self.arguments.get("--rlimit")), TColors.yellow(self.answers["sort"]), TColors.yellow(self.answers["order"]), TColors.yellow(self.answers["filter"])) headers = ["Host", "Last Run", "Play Name", "User", "+Tag", "-Tag", "vars", "Module", "IERR", "Args", "Msg"] print_table(self.results, headers=headers, question=question)
def _print_results(self): question = "Q> Ansible inventory status| host(s) '{}' returned '{}' sort '{}' order '{}' filter '{}'"\ .format(TColors.yellow(self.inventory_files), TColors.yellow(len(self.results)), TColors.yellow(self.answers["sort"]), TColors.yellow(self.answers["order"]), TColors.yellow(self.answers["filter"])) headers = ["Host", "Last Run", "Play Name", "Ok", "CH", "UR", "FL", "Time(s)", "+Tag", "-Tag", "User"] footer = "" for host_run in self.inventory_hosts: if len(host_run) > 0: # make sure list is not "" footer += TColors.blue("r " + host_run) + "\n" print_table(self.results, headers=headers, question=question, footer=footer)
def _projects_detail(self): self._connect() job_name = self.arguments.get("<jobname>") try: project = self.J[job_name] except jenkinsapi.custom_exceptions.UnknownJob: print "Error '" + TColors.red(job_name) + "' does not exist" exit(1) first_build = project.get_first_buildnumber() last_build = project.get_last_buildnumber() r_limit = self.arguments.get("--rlimit") if (last_build - first_build) > int(r_limit): first_build = last_build - int(r_limit) for buildno in range(first_build, last_build): try: build = project.get_build(buildno) except jenkinsapi.custom_exceptions.NoBuildData: build = None if build: # Status color status = build.get_status() if build.get_status() == "SUCCESS": status = TColors.green(status) elif build.get_status() == "FAILURE": status = TColors.red(status) if build: status = TColors.yellow(status) # Color duration duration = format_last_run(build.get_duration()) # Color timestamp last_run = format_last_run(build.get_timestamp(), color=False) self.results.append([buildno, last_run, duration, status]) # Print results headers = ["No.", "Last run", "Exec time", "Status"] print_table(self.results, headers=headers)
def _projects_status(self): self._connect() for job in self.J.keys(): name = job.split("-") if len(name) != 2: print "Error Jenkins job '{}' violates name SKIPPING JOB. Name example 'ansible-env-project_name.yml'"\ .format(name) return False # Check if this job has last build try: build = self.J[job].get_last_build() except jenkinsapi.custom_exceptions.NoBuildData: build = None if build: buildno = build.buildno # Status color status = build.get_status() if build.get_status() == "SUCCESS": status = TColors.green(status) elif build.get_status() == "FAILURE": status = TColors.red(status) else: status = TColors.yellow(status) # Color duration duration = format_last_run(build.get_duration()) # Color timestamp last_run = format_last_run(build.get_timestamp()) else: buildno = " - " status = " - " duration = " - " last_run = " - " # update results self.results.append([name[0], name[1], buildno, last_run, status, duration]) # Print results headers = ["ENV", "Name", "no", "Last Run", "Status", "Exec Time"] print_table(self.results, headers=headers)