(Extracted from #2328)
(See also #2328 (comment), which mentions that asm-api also suffers the same versioning issue)
tr '-' '.' conflates semver and build number
Lines 14–15 normalise - to . in both inputs:
normalized_version1=$(echo "$1" | tr '-' '.')
normalized_version2=$(echo "$2" | tr '-' '.')
For plugins versioned as X.Y-<buildnum>.v<sha> (e.g. apache-httpcomponents-client-5-api), this fuses the semver and the build number into a single dotted string. A release moving from 5.6-191.vb_47e2b_41c698 to 5.6.1-195.v65ffe15189a_d becomes a comparison of 5.6.191.vb_47e2b_41c698 vs. 5.6.1.195.v65ffe15189a_d. The older 5.6 line carries a high build number, so sort --version-sort ranks it after the newer 5.6.1 line.
Suggested fix
A fix purely in shell heuristics is harder, since - carries semantic meaning in some plugin versioning schemes (separating a semver from a build identifier) and not in others. The most robust fix is probably to delegate to Jenkins's own hudson.util.VersionNumber, or at minimum to split the string on a richer delimiter set before comparing segment-wise. Open to suggestions on which direction is preferred before sending a patch.
(Extracted from #2328)
(See also #2328 (comment), which mentions that
asm-apialso suffers the same versioning issue)tr '-' '.'conflates semver and build numberLines 14–15 normalise
-to.in both inputs:For plugins versioned as
X.Y-<buildnum>.v<sha>(e.g.apache-httpcomponents-client-5-api), this fuses the semver and the build number into a single dotted string. A release moving from5.6-191.vb_47e2b_41c698to5.6.1-195.v65ffe15189a_dbecomes a comparison of5.6.191.vb_47e2b_41c698vs.5.6.1.195.v65ffe15189a_d. The older5.6line carries a high build number, sosort --version-sortranks it after the newer5.6.1line.Suggested fix
A fix purely in shell heuristics is harder, since
-carries semantic meaning in some plugin versioning schemes (separating a semver from a build identifier) and not in others. The most robust fix is probably to delegate to Jenkins's ownhudson.util.VersionNumber, or at minimum to split the string on a richer delimiter set before comparing segment-wise. Open to suggestions on which direction is preferred before sending a patch.