Using an environment variable to define a path when using the Docker executor

Overview

In some cases you may need to use an environment variable when specifying a path. For example: source ${CIRCLE_WORKING_DIRECTORY}/script.sh which will expand to the string literal ${CIRCLE_WORKING_DIRECTORY}/script.sh when using the Docker executor. 

 

Example error: 

Screen

 

Resolution

    1. You can use the pwd command. Example: source $(PWD)/script.sh
    2. You can use the eval command. Example:  source $(eval echo ${CIRCLE_WORKING_DIRECTORY}/script.sh)
    3. Add the following run step to your build: 
 - run:  
name: "Fix CIRCLE_WORKING_DIRECTORY"
command: echo 'CIRCLE_WORKING_DIRECTORY="${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}"' >> $BASH_ENV

 

Additional Resources: 

 

 

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.