4
votes

We have an in-house Java lib that is a dependency for many other projects, let's call it our-commons-<version>.jar. We like the idea of following semantic versioning more or less, so:

  • Major number changes when we make backwards-incompatible API changes;
  • Minor number changes when we make backwards-compatible API changes;
  • Patch number changes every time we do a build (so for us, it's really a build number); but we really will only build when fixing a bug so its close enough to true semver

Currently, we only publish to a SNAPSHOT directory on Artifactory, and overwrite the JAR that's there every time we build. Specifically, we have our project repo at:

http://arty/artifactory/simple/our-libs-snapshots/our-commons/snapshot

Where http://arty/artifactory is the Artifactory service running on the arty machine, where our-libs-snapshots is the name of the actual repo, and where our-commons is the name of our lib. The /snapshot dir is where all Bamboo builds publish to, like I said, overwriting the JAR each build. We are hardcoding our build to produce an our-commons-0.1-SNAPSHOT.jar each build.

To do this publishing, I have the following task configured as part of our Bamboo plan for our-commons:

Artifactory Deploy Task
=======================
Artifactory Serverl URL:        http://arty/artifactory
Target Repository:              our-libs-snapshots
Deployer Username:              myadmin
Deployer Password:              ******
Edit Published Artifacts:       dist/our-commons-0.1-SNAPSHOT.jar=>our-commons/snapshot
Capture & Publish Build Info:   yes (checked)

I'm trying to figure out how to get Bamboo and Artifactory working with our flavor of semver. Such that the first time we build, it will produce:

http://arty/artifactory/simple/our-libs-snapshots/our-commons/1.0.0/our-commons-1.0.0.jar

And the second time we build, it will produce:

http://arty/artifactory/simple/our-libs-snapshots/our-commons/1.0.1/our-commons-1.0.1.jar

Etc. Then, we would be able to manually indicate when we want to increase the minor number, in which case the patch number would start over again:

http://arty/artifactory/simple/our-libs-snapshots/our-commons/1.1.0/our-commons-1.1.0.jar

Same deal for major number, but incrementing that would reset both the minor and patch numbers.

Not sure where we should be adding this configurations should be added, or what they would actually look like. Any ideas?

1
Just for fun, are you coming from node.js/ruby background? :) - JBaruch
Thanks @JBaruch (+1) - nope, Java background. Why?!? - IAmYourFaja
Abusing semantic versioning to achieve snapshot behavior is a natural thing to do for developers coming from those bgs. - JBaruch

1 Answers

3
votes

What you are trying to achieve is called unique snapshots (see below). Using patch versions of semver for that is wrong (Patch version is the third number, e.g. in 10.0.3 3 is the patch version).

When working with Maven (or Gradle, or Ivy) and Artifactory, you have this feature out of the box. You need to set Artifactory repository to work with unique snapshots in repository settings and setup snapshots cleaning (usually keeping 3 to 5 last snapshots is a good practice).