Texture UVs and Array modifier
To match it automatically, you can use Object coordinates.

Change texture Mapping &gt; Box
Use Texture coordinates &gt; Object
In the Object field target your array


You can change your array and caps, but the texture will always match.