Skip to content

tr '-' '.' conflates semver and build number in versionLT() of jenkins-support script #2361

Description

@lemeurherve

(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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions