Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Non Standard Version Number #1209

troybull ·
I would like to have my version number be partially read from a build.properties file with the last "digit" auto incremented by quickbuild.

I have the following in a build.properties file
version.major=1
version.minor=3
version.bugfix=0

I would like my version number to be
1.3.0.x where x auto increments by quickbuild. This allows our developers to set major and minor (and bugfix) numbers but still has qb increment the last digit.

Any Ideas
Thanks
Troy
  • replies 8
  • views 4135
  • stars 0
robinshen ADMIN ·
Assume build.properties file exists in the workspace directory after checking out, you may add a Misc/Script step after checkout step to execute below script:
groovy:
def props = new Properties()
new File(configuration.workspaceDir, "build.properties").withInputStream {
stream -> props.load(stream)
}
build.setVersion(props["version.major"] + "." + props["version.minor"] + "." + props["version.bugfix"] + "." + vars.get("iteration").increase());


Here variable "iteration" is defined as a configuration level variable with initial value set to 1.
The build version may be defined initially as "TBD", and it will be changed to the desired version by QuickBuild after running the script step.
troybull ·
Thanks
Works like a charm
drdt ·
My team is doing the opposite, where we have the version defined and incremented by QuickBuild and then write to the buildversion.properties file and check it in.
Also works like a charm, and we don't have to ever edit the buildversion.properties file by hand when we start a new branch; we just set the new version in QuickBuild.
drdt ·
Now, coming full circle... my new team is doing the same as troybull did; reading entries from application.properties and applying them via build.setVersion(). However, for ease of use, I would like the version info from application.properties to also be reflected in the QuickBuild configuration.

Can you tell me how to do this? I am looking to do something like this:

// extract the build number from the end of the version string
def buildNumber = (configuration.getNextVersion( true ) =~ /[^\d](\d+)$/)[0][1];
// build new version string using app.version from local file
def newConfigVersion = vars.getValue( "app.version" ) + ":" + buildNumber;
// save back to config for use in the next build
configuration.setNextVersion( newConfigVersion );

But of course, configuration.setNextVersion() doesn't actually exist. Is there an alternative?
robinshen ADMIN ·
To make configuration display the correct next build version, you will need to script the build version setting, something like below:
${groovy:
if (configuration.dryRun) { // dryRun flag will be set if the version is used for displaying on GUI
// read appropriate variables to calcualte the version to be displayed
\} else {
return "other version string";
\}
}
drdt ·
If I do this, I will need to use the "iteration" variable to make sure my build number increases, which I would like to avoid.

Also, doesn't this mean that every time the UI displays 'Next Build Version', QB will be pulling down and reading my application.properties file from Git?
That sounds like a performance issue.
robinshen ADMIN ·
Unfortunately QB has to go through this to reflect version in GUI.
drdt ·
I ended up not bothering. The ''Next Build Version'' only appears in one place, and the build number of the most recent build (taken from application.properties) is also visible on that screen, so there is no need to update it. Instead, I am setting 'Next Build Version' to a vanilla build number, using that as described in build.setVersion(), and everybody is happy.