New Main Objective: Meet with Legate Rikke
Leave Dragonsreach and travel through all Whiterun (don't use Fast Travel!), ignoring the fleeing civilians and buildings on fire. You need to get to Whiterun's main gate (the above screen).
Once you're outside the city, go straight north, over the rocks, to where Legate Rikke should be giving a speech (the above screen). This is the last opportunity to save the game, because the battle commences as soon as Rikke gives the command to fight.
New Main Objective: Defend the barricades
New Main Objective: Destroy attackers
New Main Objective: Defend the drawbridge
Labels on the map: Red arrows - direction of the enemy attack; 1 - the barricade, 2 - the drawbridge; 3 - Whiterun entrance.
For starters, a few words on the principles of this battle. The Stormcloaks will be coming only from one side, namely from the south, which is near the Whiterun Stables. Their aim is to reach the main city gate, but they will have two obstacles on the way. The first is the barricade where Rikke gave her speech, and the second the raised drawbridge. If enemy soldiers break through these obstacles, it doesn't mean you failed the quest. What's more, it's not possible to loose the battle, because even if a substantial number of your allies dies, the game will still allow you to continue the defense. Consequently, the only exception is the main character's death.
Remember that you will have not only the Legionnaires on your side, but also the Whiterun soldiers. Pay attention not to incidentially attack them. I suggest using area-effect attacks and spells only at the beginning of the battle, before the masses of enemy soldiers start breaking through the barricade.
Every time a Stormcloak soldier dies, the game will inform you of the decrease in the "strength" of the attacking forces. You have to fight until that count reaches 0%.
In the first stages of the battle, focus on defending the first barricade, the place where Legate Rikke gave her speech. If your character prefers close combat, jump over the barricade and attack the approaching foes (the above screen) so as not to let them near the barricade.
If your character prefers ranged combat, place yourself on the wall over the barricade and attack from there (the above screen).
Sooner or later, the Stormcloak troops will probably destroy the whole barricade or a part of it (the above screen). According to a tip given earlier, fall back to the drawbridge, especially since many foes will run past you without stopping to deal you any damage.
As I mentioned before, the drawbridge will be raised. At first, it's best to fight on the main path leading to the bridge (the above screen). If you prefer close combat, stay on the cobblestone path, and if you prefer ranged combat, consider occupying a nearby tower or any other high ground.
What's important, the foes will prove their wits and some of them might want to use the upper path to get to the mechanism lowering the drawbridge (the above screen). Lowering the bridge doesn't mean defeat, but it's better not to let it happen and try to defend the mechanism from any sabotage.
No matter how many obstacles the Stormcloaks manage to beat, continue fighting and choose your targets carefully. Watch for the enemy General, but he'll be only marginally better that his subordinates. After a while, the game will inform you of the victory, and the remaining soldiers will flee (the above screen).
New Main Objective: Report to the Jarl of Whiterun
Go back to the drawbridge and listen to Jarl Balgruuf's speech (the above screen), thanking everyone gathered here for their sacrificial fight. Approach the Jarl afterwards; he thanks you in person and offers you the possibility of living in Whiterun (for details, report to Proventus Avenicci in Dragonsreach).
Unlocked Imperial Legion Quest: Reunification of Skyrim