How to reliably detect the executor type from within build?

Hi !

I am working on a python package that deals with starting containers on demand within tests, for example when you run them on your work station. But can also be bypassed when the tests run in an environment like CircleCI.

And, naturally, I would like to be able to test that package with CircleCI and in particular test the bypass mechanism. But for that, I would need a reliable mean to detect whether I am within a container or a vm environment, from within the build steps. I wished something as simple as reading a environment variable (e.g. CIRCLE_EXECUTOR_TYPE) but that does not exist.

So I was wondering: what else could I use ? Let me once again insist on the need for the check to be reliable.

Hi @cans,

Currently, there is no such environment variable. I will request you to open a feature request on our Ideas Portal for that.

However, you can also use the below API endpoint which tells the executor of the job:

Job Details: CircleCI API


  "name" : "artifact_test",
  "executor" : {
    "resource_class" : "medium",
    "type" : "machine"

Pawan Bahuguna