How do I debug my CI/CD?

Here’s how I debug my CI/CD.

This is a real example of debugging CircleCI jobs on a GitHub repo.

We’ll debug it locally…

Without pushing commits to the repo and waiting.

First, we notice that CI/CD is failing:

To debug my CI/CD job

When we click Details, the errors mention node-gyp:

npm ERR!   g++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1'
Debug my CI/CD with node-gyp

From experience, node-gyp has failed when changing the Node version.

Looking at package-lock.json, we’d probably expect the Node version to be 14 or lower.

That’s because the lockfileVersion is 1, which usually infers Node 14 or lower:

So let’s see if the Node version in CI is 14 or lower.

We’ll open VS Code and install the extension Local CI:

Installing Local CI in VS Code

It’ll start a free trial automatically, without entering a credit card.

Then, we’ll run the CI job on our local machine.

And enter node --version to see what the version is.

Using Local CI in VS Code

We can run the job without pushing a commit or clicking anything in the repo.

It turns out that the Node version is 16, where it should probably be 14, at least with the current dependencies.

So let’s see if changing the Node version to 14 makes this job pass.

We’ll test this without pushing any code to the repo, or triggering another failed build there.

First, we’ll add an orb for Node:

Orbs are like utility functions for CircleCI, though they’re written in .yml.

And add a node/install step to set Node to 14.18.1:

Then, we’ll commit that change in git.

And we’ll rerun this job locally, no need to push the commit yet:

Local CI job failed with an error

It failed with an error:

====>> Checkout code
Error: 
Directory (/home/circleci/project) you are trying to checkout to is not empty and not a git repository

Step failed

Maybe there was a problem with the order of the checkout step.

So let’s see if moving the checkout step before the node/install step fixes it:

We’ll rerun the job locally:

CI/CD job passes locally

It passed!

Now, let’s make sure the next job doesn’t have an obvious problem.

We’ll run the next job, py39:

Python job in CI/CD

The first few minutes of the job went well.

So let’s push to the repo, as it looks like CI should pass.

All of the the jobs passed:

All of the CI builds passed

The ideal solution might have been to upgrade the package.json dependencies so they work with Node 16 or 17.

But the idea here is to show how to debug CI/CD locally.

This debugging feedback is one of CircleCI‘s huge advantages.

No endless cycle of guessing, pushing, waiting for it to fail, guessing, pushing…

Now that you’ve seen how I debug my CI/CD, here’s a fast way to speed up your builds.

Be the first to get CI/CD tips like this

You'll get these tips before they're on the blog page. See most up-to-date ways to use CircleCI®. No spam.

Reader interactions

One Reply to “How do I debug my CI/CD?”

  1. The shorter the feedback loop, the faster you can debug.

Comments are closed.