It's probably the battery, a poor connection, or the starter motor.
Could be the solenoid, but usually when the solenoid goes bad, it just clicks once each time the button is pushed or it doesn't click at all.
What causes the clicking is low voltage. When the solenoid closes allowing amperage to flow to the starter motor, the draw of the starter causes the battery voltage to drop low enough that it can't hold the solenoid closed and it opens. As soon as it opens, voltage rises and it closes again. As soon as it closes it the cycle repeats - rat-a-tat-tat-tat-tat.
To find out if it's the battery, jump it with a known good battery (car or lawn mower battery will do) - if it works normally with jumper cables, get a new battery. If the battery is known to be good, check the ground connections on the frame. If it turns slow with a jumper battery, then it's probably the starter motor.
When you get it running, you need to check the charging system to make sure the battery isn't just draining while you ride.