Is it possible to debug a Gitlab CI build interactively?

Viewed 5365

I have a build in Gitlab CI that takes a long time (10mins+) to run, and it's very annoying to wait for the entire process every time I need to experiment / make changes. It seems like surely there's a way to access some sort of shell during the build process and run commands interactively instead of placing them all in a deploy script.

I know it's possible to run Gitlab CI tests locally, but I can't seem to find a way to access the deploy running in process, even after scouring the docs.

Am I out of luck or is there a way to manually control this lengthy build?

1 Answers

I have not found a clean way for now, but here is how I do it

  1. I start building locally gitlab-runner exec docker your_build_name
  2. I kill gitlab-runner using control + c right after the docker image to be built. You can still add the command sleep 1m as the first script line just to have time enough to kill gitlab-runner Note: gitlab-runner will create a docker and then delete it once the job is done… killing it will ensure the docker is still there - no other alternative I know for now….
  3. Manually log into the container docker exec -i -t <instance-id/tag-name> bash
  4. Run your script commands manually…
Related