def _graph_task(self, task: Task, loop_counter: int, task_vars: Dict, graph: CustomDigraph, node_name_prefix: str, color: str, parent_node_id: str, parent_node_name: str) -> bool: """ Include the task in the graph. :return: True if the task has been included, false otherwise """ self.display.vv(f"Adding {node_name_prefix.strip()}: '{task.get_name()}' to the graph") if not task.evaluate_tags(only_tags=self.tags, skip_tags=self.skip_tags, all_vars=task_vars): self.display.vv(f"The task '{task.get_name()}' is skipped due to the tags.") return False task_edge_label = str(loop_counter) if len(task.when) > 0: when = "".join(map(str, task.when)) task_edge_label += " [when: " + when + "]" task_name = clean_name(node_name_prefix + self.template(task.get_name(), task_vars)) # get prefix id from node_name id_prefix = node_name_prefix.replace("[", "").replace("]", "").replace(" ", "_") task_id = id_prefix + generate_id() edge_id = "edge_" + generate_id() graph.node(task_id, label=task_name, shape="octagon", id=task_id, tooltip=task_name) graph.edge(parent_node_name, task_id, label=task_edge_label, color=color, fontcolor=color, style="bold", id=edge_id) self.graph_representation.add_link(parent_node_id, edge_id) self.graph_representation.add_link(edge_id, task_id) return True
def _add_task(self, task: Task, task_vars: Dict, node_type: str, parent_node: CompositeNode) -> bool: """ Include the task in the graph. :return: True if the task has been included, false otherwise """ # Ansible-core 2.11 added an implicit meta tasks at the end of the role. So wee skip it here. if task.action == "meta" and task.implicit: return False if not task.evaluate_tags(only_tags=self.tags, skip_tags=self.skip_tags, all_vars=task_vars): display.vv( f"The task '{task.get_name()}' is skipped due to the tags.") return False display.vv(f"Adding {node_type} '{task.get_name()}' to the graph") task_name = clean_name(self.template(task.get_name(), task_vars)) parent_node.add_node( target_composition=f"{node_type}s", node=TaskNode( task_name, generate_id(f"{node_type}_"), when=convert_when_to_str(task.when), raw_object=task, parent=parent_node, ), ) return True
def _emit_task_block_opened(self, task: Task): self._last_task_block_name = task.get_name() sys.stdout.write(f"##teamcity[blockOpened name='{self._last_task_block_name}']") sys.stdout.flush() self._is_task_block_open = True