From Sahih Bukhari (Hadith 2043):
Narrated Ibn `Umar:that `Umar had vowed in the Pre-Islamic period to perform I`tikaf in Al-Masjid-al-Haram. (A subnarrator thinks that `Umar vowed to perform I`tikaf for one night.) Allah's Messenger (ﷺ) said to `Umar, "Fulfill your vow
Reference: Bukhari 2043