1

I have a Gitlab CI/CD pipeline which:

  • builds Spring Boot app
  • packages it to a Docker image
  • deploy the image using docker run ...

I'd like to be able to validate the service after deployment. I want to be informed by the pipeline about the failure. I guess I need an additional healthcheck step in the pipeline to validate the service.

Is there any best practices for this task? Is there any ready to use solutions?

Petr Aleksandrov
  • 1,434
  • 9
  • 24

1 Answers1

1

It's possible to implement the check using spring actuator + curl + grep.

The pipeline:

check-spring-actuator-health:
  image: curlimages/curl
  stage: Health Ckeck
  script:
# exit with error if actuator/health doesn't return 'UP'
    - curl $ACTUATOR_HEALTH_URL | grep "{\"status\":\"UP\"}" || ( echo Helth Check Failed Actuator=$ACTUATOR_HEALTH_URL && exit 2; )

This step fails it the actruator/health URL isn't available or returns anything but {"status":"UP"}

Petr Aleksandrov
  • 1,434
  • 9
  • 24