title: How can I use the version from my build.gradle file in my bitbucket-pipelines.yml file
body: <p>Currently when I change the version number in my project I have to define it in my build.gradle file and several places in my bitbucket-pipelines.yml.  This is because I have scripts to upload files to my project's Downloads folder.  Is there a way to get the version from the build.gradle file?  I would like to just update one file when I increment the version.</p>
  
  <p>build.gradle</p>
  
  <pre><code>plugins {
      id 'java'
  }
  
  def buildNumber = project.properties['buildNumber'] ?:'0'
  group 'edu.csusb.iset'
  version "2020.1-BETA"
  
  jar {
      manifest {
          attributes('Main-Class': 'edu.csusb.iset.projectname.Main',
              'Implementation-Title': 'ProjectName',
              'Implementation-Version': "$version, build $buildNumber")
      }
  
      from {
          configurations.compile.collect { it.isDirectory() ? it : zipTree(it)         }
      }
  }
  
  task packSrc(type: Tar) {
      archiveAppendix.set("src")
      archiveVersion.set("$project.version")
      archiveExtension.set("tar.gz")
      destinationDirectory = file("$buildDir/dist")
      compression = Compression.GZIP
  
      from 'build.gradle'
      from 'settings.gradle'
      from('src') {
          include '**/*'
          into "src"
      }
  }
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      ...
  }
  </code></pre>
  
  <p>bitbucket-pipelines.yml</p>
  
  <pre><code>image: openjdk:11
  pipelines:
    default:
      - step:
          name: Gradle build
          caches:
            - gradle
          script:
            - bash ./gradlew build
      - step:
          name: Deploy downloads
          trigger: manual
          caches:
            - gradle
          script:
            - bash ./gradlew build
            - pipe: atlassian/bitbucket-upload-file:0.1.6
              variables:
                BITBUCKET_USERNAME: $BITBUCKET_USERNAME
                BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
                FILENAME: build/libs/ProjectName-2020.1-BETA.jar
            - bash ./gradlew packSrc
            - pipe: atlassian/bitbucket-upload-file:0.1.6
              variables:
                BITBUCKET_USERNAME: $BITBUCKET_USERNAME
                BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
                FILENAME: build/dist/ProjectName-src-2020.1-BETA.tar.gz
  </code></pre>