Using the Long-Running Build plugin

Make a new job and select Long-Running Project and note the Detached Build section. Pick a kind of build step to run—Bourne shell for Unix slaves, or batch script for Windows slaves—and enter some commands to run in your build’s workspace.

Figure 20.1. Long-Running Build Configuration

long-running-build-img-config

When the project is built, initially the executor widget will look the same as it would for a freestyle project. During this initial phase, SCM checkouts/updates and similar prebuild steps may be performed. Soon you will see a task in the widget with the (detached) annotation. This means that your main build step is running, and should continue running even if the Jenkins server is halted or loses its connection to the slave. (So long as the connection is open, you should see any new output produced by the detached build step in your build log, with a delay of a few seconds.)

Figure 20.2. Long-Running Build Execution

exec

Finally the task label will say (post steps) while any post-build actions are performed, such as archiving artifacts or recording JUnit test results. This phase does not survive a crash: it requires a constant connection from the Jenkins master to the slave agent.