IGR J18179−1621 is a hard X-ray binary transient discovered recently by INTEGRAL. Here we report on detailed timing and spectral analysis of IGR J18179−1621 in X-rays based on available INTEGRAL and Swift data. From the INTEGRAL analysis, IGR J18179−1621 is detected with a significance of 21.6σ in the 18–40 keV band by ISGRI and 15.3σ in the 3–25 keV band by JEM-X, between 2012 February 29 and 2012 March 1. We analyse two quasi-simultaneous Swift ToO observations. A clear 11.82-s pulsation is detected above the white noise at a confidence level larger than 99.99 per cent. The pulse fraction is estimated as 22 ± 8 per cent at 0.2–10 keV. No sign of pulsation is detected by INTEGRAL/ISGRI in the 18–40 keV band. With Swift and INTEGRAL spectra combined in soft and hard X-rays, IGR J18179−1621 could be fitted by an absorbed power law with a high-energy cut-off plus a Gaussian absorption line centred at 21.5 keV. An additional absorption intrinsic to the source is found, while the absorption line is evidence for a most probable origin from cyclotron resonant scattering and suggests a magnetic field in the emitting region of ∼2.4 × 1012 G.