Aims. We wish to determine the influence of bars on the building of galaxy bulges through analysis of ages and metallicities derived from stellar absorption line-strength indices. Methods. Long-slit spectroscopy was obtained for a sample of 20 early-type barred galaxies. Line-strength indices were measured and used to derive age and metallicity gradients in the bulge region by comparing them with stellar population models. The same analysis was carried out with similar data for unbarred galaxies taken from the literature. Results. The bulges of barred galaxies seem to be more metal rich, at a given velocity dispersion (σ), than the bulges of unbarred galaxies, as measured by a few metallicity sensitive indices. There are indications that the ratio of relative abundance of alpha elements with respect to iron, [E/Fe], derived for the bulges of barred galaxies tend to lie above the values of the unbarred galaxies at a given σ. The metallicity gradients for the majority of the bulges are negative so less metal-rich towards the end of the bulge. The gradient values show a large scatter for galaxies with σ below 150 km s −1 . The age distribution is related to the presence of a bulge substructure, such as a nuclear ring or an inner disk. The metallicity of both the bulge and the bar are very well correlated, indicating a close link between the enrichment histories of both components. Conclusions. Bulges of barred early type galaxies might have experienced a different chemical enrichment than do the bulges of unbarred galaxies of the same morphological type, the same central velocity dispersion, and low inclination angles. The hinted stellar populations differences separating the bulges of barred and unbarred galaxies and the strong link between the metallicity of the bulge and the presence of a bar points to scenarios where they both form simultaneously in processes that lead to rapid and massive episodes of star formation, possibly linked to the bar formation. To confirm and generalise the results found here, it would be useful to extend the data set to a larger number of unbarred galaxies and a wider range of morphological types