Environment variable to tell if you are on 2.0?

envars

#1

Is there an environment variable we could check to tell if the build is running on 1.0 vs 2.0? Something that is unique to 2.0 or 1.0?


#2

There’s not a direct variable with a CircleCI version but you can check for the existence of CIRCLE_JOB. For example:

if [[ $CIRCLE_JOB ]]; then
  echo "We're running a CircleCI 2.0 build."
else
  echo "We're in a CircleCI 1.0 build."
fi

Curious, why do you need to do this in the first place?


#3

We have tooling in place (docker setup etc.) that we pull into the job workspace. Since 2.0 needs different docker approach we have to branch the tools for 1.0 or 2.0 jobs. One approach would be keep the tool script in one place with if/else for 1.0 vs 2.0.


#5

Since 2.0 only runs with a 2.0 config, just define your own env var for which to check.