Circleci Environment Variables

circle.yml

#1

Hello all, I was hoping to get some clarification around CircleCI env variables outlined here https://circleci.com/docs/2.0/env-vars/#adding-environment-variables-in-the-app

My circleci setup requires that I have access to CIRCLE_COMPARE_URL. However, I am noticing that under certain circumstances, CIRCLE_COMPARE_URL is not set. For example, the below has the CIRCLE_COMPARE_URL set

version: 2

    build:
      docker:
         - image: node:6.10.3

      steps:
         - run: echo "This is a proof of concept"

         - run:
            command: |
            echo "Env variables:"
            echo $CIRCLE_COMPARE_URL
            echo $CIRCLE_BRANCH
            echo $CIRCLE_BUILD_NUM
            echo $CIRCLE_SHA1

But this next config file will not have CIRCLE_COMPARE_URL set:

version: 2

jobs:

  build:
     docker:
     - image: node:6.10.3

     steps:
        - run: echo "This is a proof of concept"

       - run:
            command: |
            echo "Trying to see what env variables exist"
            echo $CIRCLE_COMPARE_URL
            echo $CIRCLE_BRANCH
            echo $CIRCLE_BUILD_NUM
            echo $CIRCLE_SHA1

workflows:
  version: 2

  build_and_test:
  jobs:
      - build

Perhaps a little outline of how these circle env variables are set would help? Or maybe even why the delta between the two is happening.

From my testing it seems that adding your job to a workflow results in CIRCLE_COMPARE_URL not being set.

Thanks All!


#2

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.