title: How to set an (environment) variable in the build script in Gitlab CI?
body: <p>I have a dummy build script in the <code>Gitlab CI</code>:</p>
  
  <pre><code>pwd
  ci_app_path=$(pwd)
  echo "INFO: current directory: $ci_app_path"
  </code></pre>
  
  <p>and I get this output when the system start the build process:</p>
  
  <pre><code>pwd
  /home/kai/gitlab-runners/gitlab-ci-runner/tmp/builds/project-1
  
  ci_app_path=$(pwd)
  
  echo "INFO: current directory: $ci_app_path"
  INFO: current directory:
  </code></pre>
  
  <p>so the variable was not set (or was set only for that line: as I know each line executed separately)</p>
  
  <p>I heard about push/pop mechanism to reach the functionality I desired, but could not find any details, how to implement that. </p>
  
  <h1>Update:</h1>
  
  <p>as I thought, each line is going executed separately. So the variable scope is only one line, where it is defined:</p>
  
  <p>script:</p>
  
  <pre><code>pwd
  ci_app_path=$(pwd) &amp;&amp; echo "INFO: current directory: $ci_app_path"
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>pwd
  /home/devuser/gitlab-runners/gitlab-ci-runner/tmp/builds/project-1
  
  ci_app_path=$(pwd) &amp;&amp; echo "INFO: current directory: $ci_app_path"
  INFO: current directory: /home/kai/gitlab-runners/gitlab-ci-runner/tmp/builds/project-1
  </code></pre>
  
  <p>I don't think that writing the whole script as a one-liner is a good idea/practice.</p>
  
  <p>How to get the variables set while executing the build script?</p>
  
  <h1>P.S.</h1>
  
  <p>actually I wonder why the whole build script must contain no empty lines?, otherwise it returns:</p>
  
  <pre><code>No such file or directory
  </code></pre>
  
  <p>and a build fails on this place</p>