If you don't want to lose the shapes as separate objects, you can group them and add the gradient using the Appearance panel.

1. Create the needed gradient (you can do it any moment by I prefer to prepare it before the Appearance changing). Add it to Swatches.
2. Group the shapes.
3. In the Appearance panel add the new Fill.
4. Choose the gradient in the Fill swatches box.

You can create and apply the gradient even without preliminary creating the swatch, just open the Gradient panel when the new fill is selected and adjust it as you want.