Shear viscosity of bubbly liquids is known to depend on both the gas volume fraction and the capillary number. Here we study the impact of confinement on their behavior by investigating the viscosity of semi-dilute bubbly liquid layers confined between two plates and characterized by a ratio of the undeformed bubble diameter to the layer thickness equal or larger than unity. For all the studied confinement ratios viscosity is shown to be smaller than the viscosity of the suspending liquid for capillary numbers larger than 0.1. Measurements of bubble deformations show that this behavior is related to bubble stretching in the direction of shear induced flow. In the limit of high capillary numbers, viscosity reaches values predicted for unconfined bubbly liquids. On the other hand, our results for smaller capillary numbers, i.e. within the range 0.001-0.1, reveal a non-monotonic variation of the viscosity as a function of the confinement ratio, exhibiting a well-defined maximum value for ratio close to 1.8. This behavior differs strongly from the reference case of unconfined bubbly liquid, and it is shown to result from both bulk and wall drag forces for the squeezed bubbles.