Jenkins can boot and shutdown slaves when needed

While configuring distributed builds with Jenkins with slaves on Amazon EC2, your first setup could make use of on-demand instances.

Meaning that Amazon manages some machines that you could start (boot) and stop (shutdown) whenever you want. Amazon bills you for the time these machines are running.

So if you want to save some money, you want these machines to be running only when you use them: in the case of Jenkins slaves, only when Jenkins has something to do on them.

Amazon helps you, by providing you a console interface that can be scripted, and plugged to other logic in Jenkins, but what could be this logic?

The Slave setup plugin lets you configure slaves as “on-demand”, by providing a hook (1) that allows you to specify – right in the configuration of the slave node – a script to be executed before connecting (2) and another one to be executed after disconnecting (3).


You can find more details in its documentation (section “on-demand slave setup”).