% Pipeline-Schema: Pipeline -> Stages -> Jobs mit needs/DAG-Pfeil
% Einbinden im Hauptdokument:
%   \usepackage{tikz}
%   \usetikzlibrary{positioning,arrows.meta,fit,backgrounds}
% und an der gewünschten Stelle:
%   \input{diagrams/pipeline_stages}

\begin{figure}[H]
	\centering
	\resizebox{\columnwidth}{!}{%
	\begin{tikzpicture}[
		node distance=4mm and 6mm,
		font=\footnotesize\sffamily,
		every node/.style={align=center},
		stage/.style={draw, rounded corners=3pt, minimum width=22mm, minimum height=6mm, fill=blue!10, font=\bfseries\footnotesize\sffamily},
		job/.style={draw, rounded corners=2pt, minimum width=22mm, minimum height=6mm, fill=white},
		arr/.style={-{Stealth[length=2mm]}},
		dagarr/.style={-{Stealth[length=2mm]}, dashed, red!70!black, thick},
		]

		% Stage-Header
		\node[stage] (s1) {lint};
		\node[stage, right=12mm of s1] (s2) {test};
		\node[stage, right=12mm of s2] (s3) {build};
		\node[stage, right=12mm of s3] (s4) {deploy};

		\draw[arr] (s1) -- (s2);
		\draw[arr] (s2) -- (s3);
		\draw[arr] (s3) -- (s4);

		% Jobs unter den Stages
		\node[job, below=of s1] (j1) {eslint};

		\node[job, below=of s2] (j2a) {unit};
		\node[job, below=of j2a] (j2b) {integration};

		\node[job, below=of s3] (j3a) {bundle};
		\node[job, below=of j3a] (j3b) {container};

		\node[job, below=of s4] (j4a) {staging};
		\node[job, below=of j4a] (j4b) {prod (manual)};

		% needs/DAG: container braucht nur bundle, nicht alle vorigen
		\draw[dagarr] (j3a.east) to[bend left=10] node[above, midway, font=\tiny\itshape] {needs} (j3b.west);

		% Pipeline-Klammer drumherum
		\begin{pgfonlayer}{background}
			\node[draw, dotted, rounded corners=4pt, fit=(s1)(s4)(j2b)(j3b)(j4b), inner sep=4mm, label={[anchor=north west, font=\small\bfseries]north west:Pipeline}] {};
		\end{pgfonlayer}

	\end{tikzpicture}%
	}
	\caption{Aufbau einer Pipeline aus Stages und Jobs. Durchgezogene Pfeile: starre Stage-Reihenfolge. Gestrichelter Pfeil: needs-Beziehung (\acs{DAG}-Modus), die unnötiges Warten verkürzt.}
	\label{fig:pipeline-stages}
\end{figure}
