Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72554

compareVersions returns 2 or -2

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Jenkins Core 2.426.2
      Pipeline Utility Steps 2.16.0

      According to the documentation, the possible return values of the step compareVersions are -1, 0 and 1.

      The following code snippet gives a return value of -2.

      // Scripted syntax
      node {
          stage('test') {
              String tag1 = '1.2.3'
              String tag2 = '1.2.3-myBranch-SNAPSHOT'
              def comparisonResult = compareVersions(v1: tag1, v2: tag2)
              echo comparisonResult.toString()
          }
      } 

      Inverting arguments v1 and v2 results in -2 as the return value.

      This return value is not documented.

      • Is this a bug?
      • Is the documentation incomplete?

      If the latter, what is the logic behind this return value, and how does it differ from -1 (or 1)?

            rsandell rsandell
            rfauvel Robin Fauvel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: