Sometimes tests can be hard to debug, especially when they’re running on a remote machine.This can be done with ssh enabled build with CircleCi using Debug via SSH option.

SSH can be enabled for already running build or with rebuild option.

  1. To enable SSH access for a running build, go to the ‘Debug via SSH’ tab and click the ‘Enable SSH for this build’ button.
    enter image description here

  2. To start a fresh build with SSH enabled, for example if you want to debug a build that has already finished, click the ‘with ssh’ button alongside ‘Rebuild’:
    enter image description here

It provides key such as ssh -p 64693 ubuntu@54.191.229.47

Now we can ssh to running build and perform whatever trouble shooting we need to do.

We can simply put this key in our console and it allows us to perform our operations for debugging. We can check directories in normal way using ls command. Then going into expected directory we can perform further operations.

Example: We wrote some rake task that runs automatically on circle ci and build fails with some error and we are not able to fix it with lack of trace. In such scenario we can debug with ssh and run such rake task with --trace option and that can help us to fix failure. Same can apply to test cases we wrote and not able to debug on circle ci.

Circle Ci documentation