Mike Cooper
Mike Cooper

Reputation: 1095

Best Practice for Build Numbers with Gradle and Jenkins

We have a small java dev environment which uses gradle, Jenkins, and Git. We use an in-house built Gradle plugin to increment build numbers using a file to store the current number. The build number is baked into each build as part of its version data. The build number file is checked into the git workspace for the project.

We are now adding Jenkins to the environment for CI. Jenkins has its own build number which we can access via env var $BUILD_NUMBER.

The downside to our in-house Gradle build number plugin is that it uses a local file and thus builds by multiple developers do not sync build numbers. If we use Jenkins BUILD_NUMBER than that is completely different sequence than the Gradle build number plugin.

What is the best practice for this type of scenario?

Upvotes: 1

Views: 1192

Answers (1)

RocketRaccoon
RocketRaccoon

Reputation: 2599

If you state that only builds provided by your CI are valid for future usage it seems that you have to rely on Jenkins BUILD_NUMBER.

If you want Jenkins job BUILD_NUMBER to be started from specific value do the following:

Manage Jenkins -> Script Console
Jenkins.instance.getItemByFullName("YOUR_JOB_NAME").updateNextBuildNumber(YOUR_BUILD_NUMBER)

Upvotes: 0

Related Questions