Debugging Bitbucket Pipelines locally

Debugging your pipelines in bitbucket can be a pain, here is one simple trick that can ease it a bit!

Posted by Mark Drew on code on May 12, 2022

Tagged under bitbucket,pipelines,devops,docker

So debugging Bitbucket Pipelines is a pain.

If you have ever developed complex pipelines sometimes the odd things catch you out, for example, recently the version of jq (https://stedolan.github.io/jq/) installed worked differently in the pipeline than on my local machine (because, of course, it would!)

The answer (after you know it) is somewhat obvious. Run the pipeline image locally!

If you look at the top of the bitbucket-pipelines.yml you will see the following:

  image: atlassian/default-image:2
  options:
   ...
  definitions:

This means that the default image that is used to run most of your pipelines is atlassian/default-image:2 !

Therefore we can run our code by running the image above:

 docker  run -it atlassian/default-image:2

And that’s it! Now you can pass environment variables as usual (with -e ) or map a volume to your code to see what happens.

Hope that saves you some more minutes today!




comments powered by Disqus