Sahih Muslim Book 20, Hadith Number 4577.

Chapter : It is good on the part of a leader to take the oath of allegiance from his forces when intending to fight, and an account of the allegiance of God’s pleasure under the tree.

It has been narrated (through a different chain of transmitters) on the authority of Jabir who said: While swearing fealty to the Holy Prophet (may peace be upon him) we did not take the oath to death but that we would not run away (from the battlefield).