1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/documentation/docs/scripts/version.md
Oliver Feldmann 8e70c72ea9 Documentation improvements
Slight improvements on various md files.
Deletion of method-based commonPipelineEnvironment documentation as it
is not used.
2017-12-06 13:24:01 +01:00

3.4 KiB

Version

Description

Handles version numbers.

Constructors

Version(major, minor, patch)

Parameters

parameter mandatory default possible values
major yes
minor yes
patch no -1
  • major - The major version number.
  • minor - The minor version number.
  • patch - The patch version number.

Exceptions

  • IllegalArgumentException:
    • If the major or minor version number is less than 0.

Example

def toolVersion = new Version(1, 2, 3)

Version(text)

Parameters

parameter mandatory default possible values
text yes
  • text - As an alternative to calling the constructor with major, minor, and patch version numbers, you can pass this as a String of format 'major.minor.patch'.

Exceptions

  • IllegalArgumentException:
    • If the text parameter is null or empty.
  • AbortException:
    • If the version text has an unexpected format.

Example

def toolVersion = new Version('1.2.3')

Method Details

equals(version)

Description

Indicates whether some other version instance is equal to this one. The two versions are considered equal when they have the same major, minor and patch version number.

Parameters

  • version - The Version instance to compare to this Version instance.

Return value

true if major, minor and patch version numbers are equal to each other. Otherwise false.

Side effects

none

Exceptions

  • AbortException:
    • If the parameter version is null.

Example

assert new Version('1.2.3').equals(new Version('1.2.3'))

isCompatibleVersion(version)

Description

Checks whether a version is compatible. Two versions are compatible if the major version number is the same, while the minor and patch version number are the same or higher.

Parameters

  • version - The Version instance to compare to this Version instance.

Return value

true if this Version instance is compatible to the other Version instance. Otherwise false.

Side effects

none

Exceptions

  • AbortException:
    • If the parameter version is null.

Example

assert new Version('1.2.3').isCompatibleVersion(new Version('1.3.1'))

isHigher(version)

Description

Checks whether this Version instance is higher than the other Version instance.

Parameters

  • version - The Version instance to compare to this Version instance.

Return value

true if this Version instance is higher than the other Version instance. Otherwise false.

Side effects

none

Exceptions

  • AbortException:
    • If the parameter version is null.

Example

assert new Version('1.2.3').isHigher(new Version('1.1.6'))

toString()

Description

Print the version number in format '..'. If no patch version number exists the format is '.'.

Parameters

none

Return value

A String consisting of major, minor and if available patch, separated by dots.

Side effects

none

Exceptions

none

Example

assert "${new Version('1.2.3')}" == "1.2.3"