Hi,
I'm wondering how I can change the version number of my project with each build from gradle using Bitbucket Pipelines.
I'm currently having a build.properties file which includes some version numbers and I've got this code in my build.gradle (all files, including the build.properties, build.gradle, gradle wrapper.jar and all the gradle scripts under 'apply from' are uploaded to the repository):
task wrapper(type: Wrapper) { gradleVersion = '3.3' } // define the properties file ext.configFile = file "build.properties" configFile.withReader { if(configFile.canRead()) { // read config. def Properties prop = new Properties() prop.load(it) def jae_build = prop['jae_build'].toInteger() + 1 prop['jae_build'] = jae_build.toString() prop.store(configFile.newWriter(), null) ext.config = new ConfigSlurper().parse prop } else { throw new GradleException("Could not read build.properties!") } } apply from: 'gradle/scripts/dependencies.gradle' apply from: 'gradle/scripts/artifacts.gradle' apply from: 'gradle/scripts/optional.gradle'
My Bitbucket-pipelines.yml:
image: java:8 pipelines: default: - step: script: # Modify the commands below to build your repository. - bash ./gradlew --version - bash ./gradlew build
So, building the code is working fine, but my gradle script does not change the build number
jae_build
in my build.properties file. This occurs only using Bitbucket pipelines. Building it with the same commands manually on my Windows 10 systems results into the change of the build number, like I want it to happen.
Any idea how to let Bitbucket pipelines change my build number in the build.properties file using gradle? (should also work locally on windows )
Thx in advance.
Community moderators have prevented the ability to post new answers.
this is an open feature request: https://bitbucket.org/site/master/issues/12838/build-number-that-increments-on-every
you might like the work around available from: https://answers.atlassian.com/questions/43899302
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.