The generation of an attosecond pulse in nitrogen molecules using spatially inhomogeneous laser fields is investigated by numerically solving the time-dependent Schrödinger equation. It is found that an isolated attosecond pulse with elliptical polarization can be generated using linearly polarized laser fields. By changing polarization direction with respect to the molecular axis, the ellipticity of the attosecond pulse can be easily controlled. At some specific angles, the intensities of the two mutually vertical harmonic components, parallel and perpendicular to the driving laser polarization direction, are comparable. Additionally, the relative phase between the two components is about π/2. As a result, it supports the generation of the isolated near-circularly polarized attosecond pulse with a duration of 155 as.