The Messenger of Allah ﷺ said, "Military expeditions are of two kinds. As for the one who sets out seeking the face of Allah, obeys the leader, spends what is dear to him, treats his companion with ease, and avoids corruption, his sleep and his wakefulness are all a reward for him. But as for the one who goes out to fight for boasting, showing off, and reputation, who disobeys the leader and spreads corruption in the land, he does not return even breaking even."
حدثنا حيوة بن شريح الحضرمي حدثنا بقية حدثني بحير عن خالد بن معدان عن أبي بحرية
عن رسول الله ﷺ أنه قال الغزو غزوان فأما من ابتغى وجه الله وأطاع الإمام وأنفق الكريمة وياسر الشريك واجتنب الفساد فإن نومه ونبهه أجر كله وأما من غزا فخرا ورياء وسمعة وعصى الإمام وأفسد في الأرض فإنه لم يرجع بالكفاف
[Its chain of transmission is daif] Recorded by Nasai, in the Book of Pledge of Allegiance, chapter on being strict about disobeying the ruler, hadith no. 4200, from the narration of Baqiyyah, who practices tadlis by harmonization, and I did not find an explicit statement of his having heard it directly, in unbroken succession. Hakim graded it sahih according to the criterion of Muslim, 2/85, and Dhahabi agreed with him (!).