Skip to content
Latchkey

Spring Boot bootRun blocking the CI job (never exits) in CI

bootRun and spring-boot:run start the application and block until it is stopped. In CI that means the step runs until the job times out, because nothing tells the server to exit.

What this error means

A CI step using ./gradlew bootRun or mvn spring-boot:run prints "Started Application in N seconds" and then hangs until the job hits its timeout and is canceled.

Spring Boot
Started ExampleApplication in 6.2 seconds (process running for 6.9)
<<< bootRun keeps running, holding the step open >>>
Error: The operation was canceled.

Common causes

bootRun is a foreground server, not a check

It is meant for local development; it stays up serving requests and never returns control to the CI step.

Used to "verify startup" without a stop condition

A job runs bootRun to see if the app boots, but provides no way to shut it down, so the step never completes.

How to fix it

Verify startup with a test, not bootRun

Assert the context loads with a lightweight test that starts and stops cleanly.

src/test/java
@SpringBootTest
class ApplicationSmokeTest {
  @Test void contextLoads() {}
}

If you must run it, background it and stop it

Start the server in the background, probe a health endpoint, then kill it.

Terminal
./gradlew bootRun &
PID=$!
timeout 60 bash -c 'until curl -sf localhost:8080/actuator/health; do sleep 2; done'
kill $PID

How to prevent it

  • Use contextLoads tests to verify the app boots in CI.
  • Never run a foreground server as a blocking CI step without a stop.
  • If a running app is required, background it, health-check, then terminate.

Frequently asked questions

What causes "bootRun hangs the CI job"?
It is meant for local development; it stays up serving requests and never returns control to the CI step.
How do I fix bootRun hangs the CI job?
Assert the context loads with a lightweight test that starts and stops cleanly.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card