title: Save gradle command result into a variable in Gitlab CI/CD
body: <p>I would like to save gradle-based project's version into a variable in gitlab-ci script. In my <code>build.gradle</code> I have:</p>
  <pre><code>tasks.register('version') {
      doLast {
          println(version)
      }
  }
  </code></pre>
  <p>It reads <code>version</code> from <code>gradle.properties</code> (let's say <code>version=0.1</code>) and returns it.</p>
  <p>I execute it as <code>gradlew version -q</code> so I get only result, with no unnecessary output. When using unix-style variable creation of command result, that is: <code>version=$(./gradlew version -q)</code>, the runner ends script. Is it possible to save the output into a variable for script?</p>
  <p>My <code>.gitlab-ci.yml</code>:</p>
  <pre class="lang-yaml prettyprint-override"><code>image: gradle:jdk11
  
  cache: &amp;wrapper
    paths:
      - .gradle/wrapper
      - .gradle/caches
  
  before_script:
    - export GRADLE_USER_HOME=`pwd`/.gradle
    - chmod a+x gradlew
  
  stages:
    - prepare
    - build
    - deploy
  
  wrapper:
    stage: prepare
    script:
      - gradle wrapper
  
  compile:
    stage: build
    script:
      - ./gradlew assemble
    artifacts:
      paths:
        - build/classes/**
        - build/libs/*.jar
    cache:
      &lt;&lt;: *wrapper
      policy: pull
  
  properties:
    stage: deploy
    script:
      - eval version=$(./gradlew version -q)
      - echo $version # not even called
  </code></pre>
  <p>I also tried to omit <code>eval</code> to have <code>version=$(./gradlew version -q)</code> in <code>script</code>, but nothing changes.</p>
  <p>CI output:</p>
  <pre><code>$ export GRADLE_USER_HOME=`pwd`/.gradle
  $ chmod a+x gradlew
  $ version=$(./gradlew version -q)
  Cleaning up file based variables
  </code></pre>