Add vars/\src\com\sphinx\BuildInfo.groovy
This commit is contained in:
1 parent
9c022dd78f
commit
480185639f
1 file changed
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package com.sphinx
|
||||||
|
|
||||||
|
// Helper class: build a version string and expose it to pipelines.
|
||||||
|
// Usage in a Jenkinsfile:
|
||||||
|
// import com.sphinx.BuildInfo
|
||||||
|
// def info = new BuildInfo(this)
|
||||||
|
// echo info.version('demo')
|
||||||
|
class BuildInfo implements Serializable {
|
||||||
|
def steps
|
||||||
|
BuildInfo(steps) { this.steps = steps }
|
||||||
|
|
||||||
|
String version(String app) {
|
||||||
|
return "${app}-1.0.${steps.env.BUILD_NUMBER}"
|
||||||
|
}
|
||||||
|
|
||||||
|
String timestamp() {
|
||||||
|
return new Date().format("yyyyMMdd-HHmmss")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user