Instantly attach to the container of a failed gitlab-ci-local job.
Today, when a job fails and you want to poke around inside its container:
gitlab-ci-local --no-cleanup
docker ps -a # find it among everything else running on your machine
docker inspect <id> # confirm it's actually the right one
docker start <id>
docker exec -it <id> sh
gitlab-ci-local --no-cleanup
ci-shell attach
ci-shell finds the right leftover container by matching CI_PROJECT_PATH /
working directory against your current repo (not just "the most recent
container" - see why), starts it, and drops you into a
shell. If it's ambiguous, it asks instead of guessing.
npm install -g ci-shell
gitlab-ci-local --no-cleanup # run your pipeline as usual
ci-shell attach # jump into the failed job's container
ci-shell attach --job build # or target a specific job by name
ci-shell clean # remove leftovers for this project
ci-shell clean --all # remove all leftover containers, any project
gitlab-ci-local doesn't label its containers, but every job container
carries the same CI_* environment variables GitLab CI itself would set
(CI_PROJECT_PATH, CI_JOB_NAME, CI_COMMIT_SHA, ...) and its working
directory is always /builds/<group>/<project>. ci-shell reads both via
docker inspect (no need to start the container first) and scores every
stopped container against your current git remote. Recency is only a
tie-breaker, never the primary signal.
Not a fork of gitlab-ci-local, not a replacement for it - it's a thin
wrapper around a capability (--no-cleanup) that's already there. Requires
gitlab-ci-local and Docker to be installed separately.
MIT