Can someone explain "build number" in PluginUpgradeTask?

Can someone explain the exact purpose of build number? I am trying to understand what to return from PluginUpgradeTask.getBuildNumber().

The linked JavaDoc above says:

Build number is specified in atlassian-plugin.xml inside element. eg: <param name=“build”>1</param>

Unfortunately, I can’t find any example or explanation that explains when and why to set this value and what’s the impact of doing so.

Additionally, Atlassian Marketplace has a build number property per plugin version too. Is this in any way linked to or based off <param name="build">1</param>?

Return an integer > 0, for example 1.
For the next migrations that you need, return a number bigger than the last number you’ve used (e.g. 2, 3, 4 …).
You can have multiple migrations (Java classes implementing PluginUpgradeTask) and they will be run in order. The build number should be greater than the last migration done. I would avoid having the same build number in two different migrations.

A couple of notes:

  • sources for the plugin upgrader are in sal-core (just 2 files under sal/core/upgrade). Example: https://maven.atlassian.com/maven-public/com/atlassian/sal/sal-core/3.1.0/
  • the current build number is saved in the table bandana (bandatacontext="_GLOBAL", bandakey="${pluginkey}:build", bandanavalue="${lastBuildNumber}"
  • the key should be > 0. The build number is considered 0 if it’s missing from the database, so if you have a migration, it needs to be at least 1.
  • I have seen no need for ‘param name=“build”’ in atlassian-plugin.xml.
1 Like