title: Environment variables for docker-compose inside of Jenkins
body: <p>I've the following setup:</p>
  
  <p>Jenkins environment running docker-compose but I need to pass environment variables to the yml file:</p>
  
  <p>sample docker-compose.yml</p>
  
  <pre><code>version: '2'
  
  services:  
    logon_server:
      build: .
      image: my_server:0.0.1
      ports:
        - "9200:9200"
      command: ${DOCKER_CMD_EXEC}
      networks:
        - my_ntwrk
  
  networks:
    my_ntwrk:
  </code></pre>
  
  <p>When I run the following script from a shell prompt on my mac, I can pass different commands to be executed and everything works:</p>
  
  <p>exec-tests.sh</p>
  
  <pre><code>#!/bin/bash
  
  chmod 755 docker/exec-*.sh
  
  # Setup env variables
  export DOCKER_CMD_EXEC=/ci_e2e.sh
  
  # Optional: record current versions
  docker -v &amp;&amp; docker-compose -v
  
  echo `whoami` 
  
  echo `sudo -E -u admin printenv`
  
  # Build, deploy and run E2E test cases
  sudo -E -u admin docker-compose up --no-color --abort-on-container-exit
  </code></pre>
  
  <p>When I run the script inside of my jenkins job, under 'Build Environment' -> 'Execute Shell' -> 'Command', here is an image of what I'm talking about:</p>
  
  <p><a href="https://wiki.jenkins-ci.org/download/attachments/59511381/build-user-vars-plugin-sample-usage.png?version=1&amp;modificationDate=1329374467000" rel="noreferrer">Example of shell command</a></p>
  
  <p>I get the following error:</p>
  
  <pre><code>The DOCKER_CMD_EXEC variable is not set. Defaulting to a blank string
  </code></pre>
  
  <p>I've tried running this as root and as the default user 'admin' which is what jenkins is run as. I've tried to make the environment variables inheritable, tried printing the env's and everything looks good. </p>
  
  <p>I can re-produce the error on my mac by just unsetting the DOCKER_CMD_EXEC but I cant figure out why this happening in jenkins!</p>
  
  <p>Any help would be appreciated!</p>
  
  <p>Thanks.</p>
  
  <p>J</p>