jfrog / teamcity-artifactory-plugin

TeamCity plugin that enables traceable build artifacts with Artifactory
https://www.jfrog.com/confluence/display/JFROG/TeamCity+Artifactory+Plug-in
Apache License 2.0
42 stars 47 forks source link

Fix: Issue with the next development version logic. #67

Open doublefx opened 5 years ago

doublefx commented 5 years ago

The next development version is computed by increment of one, for either the buildNumber when present or the patch version even when those one are set to zero.

The current logic does not allow us to use the patch version for hotfixes only.

For example, given a current development version 6.144.0-SNAPSHOT, if the logic is to increment the patch version, at release time, the plugin will propose 6.144.1-SNAPSHOT but I need 6.145.0-SNAPSHOT and I will have to manually update the next development version manually and that at every single release.

Now, if we change the logic to increment only when it is not zero, I only need to change the next development version when a major change is required, the rest of the time the desired version part will be incremented automatically.

A config parameter "org.jfrog.artifactory.releaseManagement.nextDevelopmentVersionStrategy" that can be set either in the build configuration and / or project configuration, so the nextDevelopmentVersionStrategy can use for only specific projects and / or builds. When not set, set to "default" or set to unknown, the default nextDevelopmentVersionStrategy is used, when set to "ignore_zeros", it will apply that specific nextDevelopmentVersionStrategy.

The new logic would propose by default, given a strategy: release version ==> next development version :

UNKNOWN : 6.0.0 ==> 6.0.1-SNAPSHOT UNKNOWN : 6.1.0 ==> 6.1.1-SNAPSHOT UNKNOWN : 6.0.1 ==> 6.0.2-SNAPSHOT UNKNOWN : 6.1.0-0 ==> 6.1.1-SNAPSHOT UNKNOWN : 6.1.0-22 ==> 6.1.0-23-SNAPSHOT UNKNOWN : 6.1 ==> 6.1.1-SNAPSHOT UNKNOWN : 6 ==> 6.0.1-SNAPSHOT

DEFAULT : 6.0.0 ==> 6.0.1-SNAPSHOT DEFAULT : 6.1.0 ==> 6.1.1-SNAPSHOT DEFAULT : 6.0.1 ==> 6.0.2-SNAPSHOT DEFAULT : 6.1.0-0 ==> 6.1.1-SNAPSHOT DEFAULT : 6.1.0-22 ==> 6.1.0-23-SNAPSHOT DEFAULT : 6.1 ==> 6.1.1-SNAPSHOT DEFAULT : 6 ==> 6.0.1-SNAPSHOT

IGNORE_ZEROS : 6.0.0 ==> 7.0.0-SNAPSHOT IGNORE_ZEROS : 6.1.0 ==> 6.2.0-SNAPSHOT IGNORE_ZEROS : 6.0.1 ==> 6.0.2-SNAPSHOT IGNORE_ZEROS : 6.1.0-0 ==> 6.2.0-SNAPSHOT IGNORE_ZEROS : 6.1.0-22 ==> 6.1.0-23-SNAPSHOT IGNORE_ZEROS : 6.1 ==> 6.2.0-SNAPSHOT IGNORE_ZEROS : 6 ==> 7.0.0-SNAPSHOT

Everything works almost as before except for when the lowest version part is zero.

jetersen commented 5 years ago

@doublefx You might want to set up an email alias on your GitHub account 🥇 Or look into fixing your git user.email config 😅 to get proper credit for your commits 🏆 https://help.github.com/articles/adding-an-email-address-to-your-github-account/ https://help.github.com/articles/setting-your-commit-email-address-in-git then to amend your commits: https://stackoverflow.com/a/3042512

doublefx commented 5 years ago

arrf, you are right, I don't mind about the credit but mind about that Signed-off :-) I will push again

jetersen commented 5 years ago

The from inside the .patch says the same as Signed-off so :man_shrugging:

doublefx commented 5 years ago

Should be ok now.

jetersen commented 5 years ago

https://github.com/jfrog/teamcity-artifactory-plugin/commit/e3fa30d0694d9da9e6a78b1b995d6a0ddd9efba2.patch you sure? :) You should be able to add the email address to your GitHub account. https://help.github.com/articles/adding-an-email-address-to-your-github-account/

doublefx commented 5 years ago

Can you please check this new patch? if ever it did not work I'll have to do it later and in another way.

jetersen commented 5 years ago

you can always check yourself :) just click the commit and add .patch

Looks alright to me :laughing:

doublefx commented 5 years ago

Good one, I did not know the trick, thanks. Regarding the credit, I really don't care and won't take any, my github account is still set to my Apache email address, what I care though is not using my company email address ;-)

jetersen commented 5 years ago

Well, you got the credit :laughing: GitHub says so, it is based on your From line in the .patch image

eyalbe4 commented 5 years ago

@doublefx, Thank you for working on this creating this pull request.

I think that introducing the concept of multiple strategies (DEFAULT, IGNORE_ZEROS and UNKNOWN) can cause some confusion. I'm not sure how easy it will be to explain each strategy and this will probably not satisfy all possible versioning requirements.

I suggest going for a simpler approach. Let me know what you think:

  1. Let's have the existing algorithm as default.
  2. Let's also allow setting an optional regular expression, with one capturing group, which will indicate which portion of the version to increments.

Examples:

[0-9]+.[0-9]+.([0-9]+)-SNAPSHOT --> Increment the patch version.
[0-9]+.([0-9]+).[0-9]+-SNAPSHOT --> Increment the minor version.
CLAassistant commented 4 years ago

CLA assistant check
All committers have signed the CLA.

eyalbe4 commented 4 years ago

@doublefx, Please let me know if you'd like to continue promoting this.