You can combine a dodge trap with a bridge to make a catch 'em all trap.
WWWWWWWWWWDWWWWWWWWWW
WWWWWWWWW...WWWWWWWWW
WWWWWWWWW...WWWWWWWWW
WWWWWWWWWLLLWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWW<WWWWWWWWWW
..........B..........
..........B..........
..........B..........
SSSSSSSSSSBSSSSSSSSSS ===> to fortress
.....................
WWWWWWWWWWWWWWWWWWWWW
W = wall
L = lever, all levers linked to all spikes/bridges
D = door to control room from fortress
. = empty space/pit/floor
< = ramp down to lower level, retracting bridge over ramp, linked to *different* lever, used to seal/open pit
B = retractable bridge over floor linked to lever
S = spike traps over floor linked to lever
So you have a narrow walkway leading into your fortress. Put spike traps linked to levers. Each lever controls all traps, so only a single lever is needed to control everything. This gives you a great deal of redundancy so there is no break in pulling the levers until you tell the dwarves to stop.
The spike traps will cause them to dodge into the pit. The pit is only 1 Z level deep, with a retracting bridge for a floor. More importantly, there is always a continuous and never interrupted path from the pit to the fortress to the invaders. At no point is the path ever broken, aside from the retracting bridge over the top of the ramp, which is what you extend if you want to seal off your captured goblins.
When the leader attacks, he will hit the spike traps, and dodge. He will fall into the pit. Its only 1Z level so he will not be harmed. His soldiers will then try to path to the leader down in the pit, and there is a clear path to him, but a combination of spike traps and retracting bridges will cause everyone to dodge or be flung into the pit. As they try to escape they will make it up the ramp, only to be flung down into the pit again. I use a combination of spike traps on the main walkway, with retracting bridge, because if they're trying to escape from the pit they might be slightly injured and thus unable to dodge. Rather than kill them, the retracting bridge will just fling them around randomly, so they fall back into the pit without being harmed.
Keep this going and the redundant levers being pulled until all goblins are in the pit. Then seal off the bridge over the ramp. Now no one can escape!
From here you can open up the retracting bridges the goblins are all standing on, pulling out the floor from under them. Then they can fall into whatever fate you have build for them. Magma? Water? Firing range? Solid granite after falling 100Z levels? Barracks full of on duty soldiers? Up to you.