  We present the study of deuteration of cyanoacetylene (HC$_3$N) towards a
sample of 28 high-mass star-forming cores divided into different evolutionary
stages, from starless to evolved protostellar cores. We report for the first
time the detection of DC$_3$N towards 15 high-mass cores. The abundance ratios
of DC$_3$N with respect HC$_3$N range in the interval 0.003$-$0.022, lower than
those found in low-mas protostars and dark clouds. No significant trend with
the evolutionary stage, or with the kinetic temperature of the region, has been
found. We compare the level of deuteration of HC$_3$N with those of other
molecules towards the same sample, finding weak correlation with species formed
only or predominantly in gas phase (N$_2$H$^+$ and HNC, respectively), and no
correlation with species formed only or predominantly on dust grains (CH$_3$OH
and NH$_3$, respectively). We also present a single-dish map of DC$_3$N towards
the protocluster IRAS 05358+3543, which shows that DC$_3$N traces an extended
envelope ($\sim$0.37 pc) and peaks towards two cold condensations separated
from the positions of the protostars and the dust continuum. The observations
presented in this work suggest that deuteration of HC$_3$N is produced in the
gas of the cold outer parts of massive star-forming clumps, giving us an
estimate of the deuteration factor prior to the formation of denser gas.
