20

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?

jamesfacts
  • 371
  • 2
  • 14
  • as long as you're using docker images, you can still run your jobs locally (see e.g. https://bryce.fisher-fleig.org/blog/faster-ci-debugging-with-gitlabci/index.html for some complete reference) and restart the containers/inspect them (i.e. with `docker logs`) upon failure – Alfageme Oct 16 '17 at 17:41
  • Have you ever found a solutions to this? I have to test the integration of my builds with a Kubernetes cluster connected via their proprietary panel so local builds don't really help here. I've always done it on https://travis-ci.com/ so I just assumed I could do it with GitLab too. Apparently I was wrong `¯\_(ツ)_/¯` – Francesco Casula Mar 16 '18 at 15:51
  • @FrancescoCasula I am sorry to say I still have not solved this issue. If I come across a fix I will absolutely update the thread. – jamesfacts Mar 20 '18 at 19:01

1 Answers1

7

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…
Flavien Volken
  • 19,196
  • 12
  • 100
  • 133
  • This approach works for me but notice that jobs are built under /builds within the container so after executing `docker exec -i -t bash` you should run `cd /builds/project-0/` an there you will find the job root. – Juampy NR Aug 14 '19 at 22:33
  • What do you mean by 'your_build_name'? I have successfully installed and registed the gitlab-runner in my local machine. – Keerthivasan Oct 22 '20 at 12:59