This is not true as stated in the (triangulated) derived category of complexes of sheaves. There is a corrected version for the derived $\infty$-category of complexes of sheaves, but then the cocycle condition is not a condition but (a lot of) extra *data*: a homotopy between $f_{jk} \circ f_{ij}$ and $f_{ik}$ on $U_i \cap U_j \cap U_k$, and higher versions of this. This type of descent (glueing) is exactly what $\infty$-categories of sheaves are designed to do. (For complexes of *abelian* sheaves, as opposed to sheaves of sets/spaces, you should be able to make due with dg categories, but I think the $\infty$-language is becoming the dominant one these days.)

I will give examples of the failure of existence and uniqueness. We will always assume that every finite intersection $U_I := \bigcap_{i \in I} U_i$ is connected (including $U_\varnothing = X$). For both examples, I'll use Yoneda's description of higher $\operatorname{Ext}$ functors; see e.g. Tags 06XT and 06XU. In particular, any class $\alpha \in \operatorname{Ext}^2(\underline{\mathbf Z},\underline{\mathbf Z}) = H^2(X,\mathbf Z)$ gives a complex $Z^\bullet = (Z^{-1} \to Z^0)$ with $H^i(Z^\bullet) = \underline{\mathbf Z}$ if $i \in \{-1,0\}$ and $0$ otherwise. If $\alpha = 0$, then this complex is (non-canonically) quasi-isomorphic to $\underline{\mathbf Z} \oplus \underline{\mathbf Z}[1]$. If moreover $H^1(X,\mathbf Z) = 0$, then $\operatorname{End}(\underline{\mathbf Z} \oplus \underline{\mathbf Z}[1]) = \mathbf Z^2$, so $\operatorname{Aut}(\mathbf Z \oplus \mathbf Z[1]) = \{\pm 1\}^2$. We will study complexes $K_i$ on $U_i$ of the form $Z^\bullet$ for some class $\alpha \in H^2(U_i,\mathbf Z)$, where the glueing maps $K_i|_{U_i \cap U_j} \to K_j|_{U_i \cap U_j}$ act as the identity on $H^{-1} = H^0 = \underline{\mathbf Z}$.

**Example 1.** Let's start with an example of non-uniqueness. Take a topological space $X$ with $H^2(X,\mathbf Z) \neq 0$ covered by opens $U_1, \ldots, U_n$ such that $U_I$ is contractible if $I \neq \varnothing$. For instance, Bott and Tu give an example of such a covering for $X = S^2$ with 4 opens [BT82, Ex. 9.3].

Take a nonzero class in $H^2(X,\mathbf Z)$ and produce $K = Z^\bullet$ with $H^{-1}(K) = H^0(K) = \underline{\mathbf Z}$ as above. For any $i$, there is a unique quasi-isomorphisms $K|_{U_i} \stackrel\sim\to \underline{\mathbf Z}\oplus \underline{\mathbf Z}[1]$ acting as the identity on $H^{-1}$ and $H^0$, since $H^1(U_i,\mathbf Z) = H^2(U_i,\mathbf Z) = 0$. Uniqueness means that the cocycle we get on $K'_i = \underline{\mathbf Z} \oplus \underline{\mathbf Z}[1]$ from the quasi-isomorphism $K|_{U_i} \cong K'_i$ is the trivial cocycle, i.e. the complexes $K$ and $\underline{\mathbf Z} \oplus \underline{\mathbf Z}[1]$ on $X$ both give the same cocycle.

**Example 2.** For non-existence, take a contractible topological space $X$ with a covering by opens $U_i$ such that $H^1(U_i \cap U_j,\mathbf Z) = 0$ for all $i, j$ and all maps $H^2(U_I,\mathbf Z) \to H^2(U_J,\mathbf Z)$ for $\varnothing \subsetneq I \subseteq J$ are isomorphisms of nonzero abelian groups (we will denote this group by $H^2(U)$). For instance, let $X = \mathbf R^3$, take three non-collinear points $a_1,a_2,a_3 \in \mathbf R^3$, and for $i \in \{1,2,3\}$, let $U_i$ be the complement in $X$ of the line segment from $a_j$ to $a_k$ if $\{1,2,3\} = \{i,j,k\}$. Then each $U_i$ and each $U_i \cap U_j$ is homotopy equivalent to $S^2$, whereas $U_1 \cap U_2 \cap U_3$ has $H^1 = H^2 = \mathbf Z$ (see for instance this answer).

Now take a nonzero class $\alpha \in H^2(U)$, and define $K_I$ on $U_I$ to be the complex $Z^\bullet$ associated with $\alpha \in H^2(U_I,\mathbf Z)$. The isomorphisms
$$H^2(U_i,\mathbf Z) \to H^2(U_i \cap U_j,\mathbf Z) \leftarrow H^2(U_j,\mathbf Z)$$
give quasi-isomorphisms $f_{ij} \colon K_i|_{U_i \cap U_j} \stackrel\sim\to K_{i,j} \stackrel\sim\leftarrow K_j|_{U_i \cap U_j}$, which evidently satisfy the cocycle condition. But they do not glue to a complex $K$ on $X$: such a complex would have $H^0(K) = H^{-1}(K) = \underline{\mathbf Z}$ and $H^i(K) = 0$ for $i \neq \{-1,0\}$, since the cocycle acts trivially on $H^i$ for all $i$. Thus it is represented by a class in $\operatorname{Ext}^2(\underline{\mathbf Z},\underline{\mathbf Z}) = H^2(X,\mathbf Z) = 0$ whose restriction to each $U_i$ is the nonzero class $K_i$, which is absurd.

**References.**

[BT82] R. Bott, L. W. Tu, *Differential forms in algebraic topology*. Graduate Texts in Mathematics, **82**. Springer-Verlag, 1982.