title: Update TeamCity Build Number with version in Gradle build script
body: <p>I have a gradle build script as below:</p>
  
  <pre><code>buildscript {
      repositories {
           //Some repo
      }
          dependencies {
              classpath "com.palantir.gradle.gitversion:gradle-git-version:0.8.0"
          }
      }
  }
  apply plugin: 'com.palantir.git-version'
  
  version gitVersion()
  </code></pre>
  
  <p>I would like to update TeamCity <code>build number</code> with the value of <code>version</code> from the <code>gitVersion()</code> function. Is there anyway to  do that?</p>
  
  <p>I know in Maven world, for TeamCity to pick-up the version in <code>pom.xml</code> file, I can specify TeamCity build number equal to <code>%maven.project.version%</code>. But how to achieve the same thing with Gradle?</p>
  
  <p><strong><em>An attempt:</em></strong></p>
  
  <p>Also, I thought of a solution to create a Gradle Exec task to update TeamCity build number via <strong>Service Message</strong> (doc <a href="https://confluence.jetbrains.com/display/TCD7/Build+Script+Interaction+with+TeamCity" rel="nofollow noreferrer">here</a>):</p>
  
  <pre><code>task updateTeamCityBuildNumber(type: Exec) {
      x=version
      echo $x
      echo "##teamcity[setParameter name='buildNumber' value='${x}']"
  }
  </code></pre>
  
  <p>But I got this error:
  <code>Could not set unknown property 'x' for task ':updateTeamCityBuildNumber' of type org.gradle.api.tasks.Exec</code></p>
  
  <p>So another question on this direction is that how do I pass the variable <code>version</code> into the Gradle Exec task and refer to it in the "echo" statement below?</p>
  
  <p>(My TeamCity build agent is Linux)</p>
  
  <p>Thanks and let me know if you need more details</p>