Slight improvements on various md files. Deletion of method-based commonPipelineEnvironment documentation as it is not used.
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
orminor
version number is less than0
.
- If the
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 withmajor
,minor
, andpatch
version numbers, you can pass this as a String of format 'major.minor.patch'.
Exceptions
IllegalArgumentException
:- If the
text
parameter isnull
or empty.
- If the
AbortException
:- If the version
text
has an unexpected format.
- If the version
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
isnull
.
- If the parameter
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
isnull
.
- If the parameter
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
isnull
.
- If the parameter
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"