Context. The xGASS and xCOLD GASS surveys have measured the atomic (HI) and molecular gas (H2) content of a large and representative sample of nearby galaxies (redshift range of 0.01 $lt$ z $lt$ 0.05). Aims. We present optical longslit spectra for a subset of the xGASS and xCOLD GASS galaxies to investigate the correlation between radial metallicity profiles and cold gas content. In addition to data from Moran et al. (2012), this paper presents new optical spectra for 27 galaxies in the stellar mass range of 9.0 $leq$ log Mstar/Msun $leq$ 10.0. Methods. The longslit spectra were taken along the major axis of the galaxies, allowing us to obtain radial profiles of the gas-phase oxygen abundance (12 + log(O/H)). The slope of a linear fit to these radial profiles is defined as the metallicity gradient. We investigated correlations between these gradients and global galaxy properties, such as star formation activity and gas content. In addition, we examined the correlation of local metallicity measurements and the global HI mass fraction. Results. We obtained two main results: (i) the local metallicity is correlated with the global HI mass fraction, which is in good agreement with previous results. A simple toy model suggests that this correlation points towards a local gas regulator model; (ii) the primary driver of metallicity gradients appears to be stellar mass surface density (as a proxy for morphology). Conclusions. This work comprises one of the few systematic observational studies of the influence of the cold gas on the chemical evolution of star-forming galaxies, as considered via metallicity gradients and local measurements of the gas-phase oxygen abundance. Our results suggest that local density and local HI mass fraction are drivers of chemical evolution and the gas-phase metallicity.