Various static methods which doesn't have a class.
| Type Params | Return Type | Name and description |
|---|---|---|
|
static java.lang.String |
dumpProperties(java.lang.Object obj)Return all properties and values of an object |
|
static java.lang.String |
escapeXml(java.lang.String text)Escape special characters in text to make it safe to put in XML |
|
static java.lang.String |
getBuildIdentifier(java.lang.Object env, java.util.Map args = [:])Get Build Identifier. |
|
static java.util.logging.Logger |
getLogger(java.lang.String name = '')Get a logger instance |
|
static java.lang.String |
getReleaseIdentifier(java.lang.Object env, java.util.Map mappings = ['master': 'SNAPSHOT'])Get release identifier from branch name. |
|
static java.lang.String |
getTimestamp(java.lang.String format = "yyyyMMddHHmmss")Get current timestamp in a specific format. |
|
static java.lang.String |
getUriQueryString(java.util.Map params = [:])Convert a Map to URL query string. |
|
static java.lang.String |
interpretSemanticVersionBump(java.util.Map versionTrunks, java.lang.String bump)Convert a version bump string to exact new version string. |
|
static java.lang.String |
loadResource(java.lang.String path)Read resource file |
|
static java.util.Map |
parseFileExtension(java.lang.String file)Return file name and extension with the given file name |
|
static java.util.Map |
parseSemanticVersion(java.lang.String version)Parse semantic version into trunks. |
|
static java.lang.String |
sanitizeBranchName(java.lang.String branch)Sanitize branch name so it can only contains: |
|
static java.util.Map |
toMap(java.lang.Object obj)Convert an Object to Map |
|
static java.util.Map |
waitForInput(java.lang.Object jenkinsSteps, java.util.Map args = [:])Pause the Jenkins pipeline and wait for end-user input. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Return all properties and values of an object
obj - Object to checkEscape special characters in text to make it safe to put in XML
params - text to escapeGet Build Identifier.
Example output:
20180101.010101-pr-11-1: PR-11 branch build #1 at 20180101.01010120180101.010101-13: master branch build #13 at 20180101.01010120180101-010101-13: master branch build #13 using "%Y%m%d-%H%M%S" formatincludeTimestamp - Boolean|String, default is true. If add timstamp to the build identifier, or specify a
formatting string. Support format is using Java DateTimeFormatter:
https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.htmlexcludeBranches - List|String, The branches should not be excluded from identifier. Set it to
'__ALL__' to completely exclude branch name from the
identifier.includeBuildNumber - Boolean, default is true. If add build number to the build identifierGet a logger instance
import groovy.util.logging.Log then use @Log annoutation to
enable logging.name - name of the loggerGet release identifier from branch name.
env.BRANCH_NAME to get branch name, so it only works on
Multibranch Pipeline.
Example output:
SNAPSHOT: default release name on master branchpr-13: pull request #13Usage examples:
getReleaseIdentifier(env, ['master': 'snapshot', 'staging': 'latest'])BRANCH_NAME key.mappings - mappings of branch name and identifierGet current timestamp in a specific format.
format - Format of datatime. Default value is yyyyMMddHHmmss20190101010101Convert a Map to URL query string.
['param1': 'value1', 'param2': 234], should expect a result of
param1=value1¶m2=234params - map to hold the URL parametersConvert a version bump string to exact new version string.
npm version.versionTrunks - Map of version trunks returned from parseSemanticVersion(String).bump - New expected version. For example, patch, or minor.Read resource file
String content = Utils.loadResource('src/test/resources/my-file.txt')
path - path to the resource fileReturn file name and extension with the given file name
file - file name to parseParse semantic version into trunks.
The result should be a Map with these keys:
1.2.3-alpha.1+20190101010101, the method should return an output of:version - the version string to parseSanitize branch name so it can only contains:
String branch = 'stagings/mytest' String santizedBranch = Utils.sanitizeBranchName(branch) assert santizedBranch == 'stagings-mytest'
branch - branch nameConvert an Object to Map
obj - Object to convertPause the Jenkins pipeline and wait for end-user input.
The result should be a Map include these keys:
timeout: a Boolean value if the input has reached timeout.proceed: a Boolean value if the pipeline should proceed. It will be true only if
the input is Approved to proceed by a user.user: a nullable string represents who approved/rejected the input.
Map action = Utils.waitForInput(
this.steps,
[
timeout: [time: 30, unit: 'MINUTES'],
message: "Please verify before continue:"
]
)
Here is senarios what could be returned:
[timeout: true, proceed: false, user: 'TIMEOUT']: No one intervened, so the input reached timeout.[timeout: false, proceed: true, user: 'Jack T. Jia']: Jack clicked on Proceed button.[timeout: false, proceed: false, user: 'Jack T. Jia']: Jack chosed to abort the pipeline.jenkinsSteps - jenkins steps objectargs - arguments for the input:[time: 2, unit: 'MINUTES']