You can buy a ticket for €5 in advance online or at news kiosks inside the airport terminal. If you buy the ticket on board from the driver it will be slightly more expensive and cost €7. The schedules vary throughout the week, so you should consult the Cotral website in advance to plan which bus you'd like to take.