Context : Runaway stars are ejected from their formation sites well within molecular cores in giant dark clouds . Eventually , these stars can travel through the molecular clouds , which are highly inhomogeneous . The powerful winds of massive runaway stars interact with the medium forming bowshocks . Recent observations and theoretical modelling suggest that these bowshocks emit non-thermal radiation . As the massive stars move through the inhomogeneous ambient gas the physical properties of the bowshocks are modified , producing changes in the non-thermal emission . Aims : We aim to compute the non-thermal radiation produced in the bowshocks of runaway massive stars when travelling through a molecular cloud . Methods : We calculate the non-thermal emission and absorption for two types of massive runaway stars , an O9I and an O4I , as they move through a density gradient . Results : We present the spectral energy distributions for the runaway stars modelled . Additionally , we obtain light curves at different energy ranges . We find significant variations in the emission over timescales of \sim 1 yr . Conclusions : We conclude that bowshocks of massive runaway stars , under some assumptions , might be variable gamma-ray sources , with variability timescales that depend on the medium density profile . These objects might constitute a population of galactic gamma-ray sources turning on and off within years .