Sunan an-Nasa'i, Volume 5, Book 39, Hadith 4200 (DarusSalam)

It was narrated from Muadah bin Jabal that the Messenger of Allah said: "Military campaigns are of two types: as for the one who seeks the Face of Allah, obeys the imam, spends what is precious and avoids mischief, whether he is asleep or awake, he is earning reward. But as for the one who fights in order to show off and gain a reputation, and disobeys the imam and spreads mischief in the land, he comes back empty-handed." (Da 'if)

أَخْبَرَنَا عَمْرُو بْنُ عُثْمَانَ بْنِ سَعِيدٍ، قَالَ حَدَّثَنَا بَقِيَّةُ بْنُ الْوَلِيدِ، قَالَ حَدَّثَنَا بَحِيرٌ، عَنْ خَالِدِ بْنِ مَعْدَانَ، عَنْ أَبِي بَحْرِيَّةَ، عَنْ مُعَاذِ بْنِ جَبَلٍ، عَنْ رَسُولِ اللَّهِ صلى الله عليه وسلم قَالَ ‏ "‏ الْغَزْوُ غَزْوَانِ فَأَمَّا مَنِ ابْتَغَى وَجْهَ اللَّهِ وَأَطَاعَ الإِمَامَ وَأَنْفَقَ الْكَرِيمَةَ وَاجْتَنَبَ الْفَسَادَ فَإِنَّ نَوْمَهُ وَنُبْهَتَهُ أَجْرٌ كُلُّهُ وَأَمَّا مَنْ غَزَا رِيَاءً وَسُمْعَةً وَعَصَى الإِمَامَ وَأَفْسَدَ فِي الأَرْضِ فَإِنَّهُ لاَ يَرْجِعُ بِالْكَفَافِ ‏" ‏ ‏.‏

sunnah.com