title: Android Gradle 'versionCode' not read from environment variable
body: <p>I have an Android that I deploy to a Google Play alpha track trough a CI server. For the Android <code>versionCode</code> I make use of the CI build number that I inject into the Gradle script through an environment variable.</p>
  
  <p>This used to work fine; but currently Google Play is not accepting any builds. When I manually trigger a alpha upload build (using the <a href="https://github.com/Triple-T/gradle-play-publisher" rel="noreferrer">gradle-play-publisher</a> plugin) for Gradle I eventually end up with the following error:</p>
  
  <pre><code>APK has an invalid version code.
  </code></pre>
  
  <p>So when looking (using <code>aapt dump badging apk-path</code>) at the generated APK I see an empty value for the version code (<code>versionCode=''</code>).</p>
  
  <p>The relevant code from the build script:</p>
  
  <pre><code>def appVersionCode = System.getenv("BUILD_NUMBER") as Integer ?: 0
  defaultConfig {
    ...
    versionCode appVersionCode
    ...
  }
  </code></pre>
  
  <p>It seems the variable is not read correctly; however it reads <code>System.getenv("KEY_PASS")</code> correctly to use for signing.</p>
  
  <p>The variable is also set:</p>
  
  <pre><code>❯ echo $BUILD_NUMBER
  1234
  </code></pre>
  
  <p>Does anyone have an idea why this specific variable doesn't seem to be read (anymore)?</p>
  
  <p>Gradle version: 3.5 with Android Gradle plugin 2.3.1.</p>