fix(cpkg): reuse latest version number
This commit is contained in:
parent
77a7c46d3f
commit
1ddb5691ca
|
@ -1,8 +1,8 @@
|
||||||
|
import java.util.regex.Matcher
|
||||||
|
|
||||||
// Basic port of https://forge.cadoles.com/Cadoles/cpkg
|
// Basic port of https://forge.cadoles.com/Cadoles/cpkg
|
||||||
def call(Map params = [:]) {
|
def call(Map params = [:]) {
|
||||||
|
|
||||||
def currentRef = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
|
def currentRef = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
|
||||||
def baseRef = params.baseRef ? params.baseRef : currentRef
|
|
||||||
def distRepo = params.distRepo ? params.distRepo : 'dev'
|
def distRepo = params.distRepo ? params.distRepo : 'dev'
|
||||||
def dist = params.dist ? params.dist : 'eole'
|
def dist = params.dist ? params.dist : 'eole'
|
||||||
def distVersion = params.distVersion ? params.distVersion : '2.7.0'
|
def distVersion = params.distVersion ? params.distVersion : '2.7.0'
|
||||||
|
@ -28,7 +28,7 @@ def call(Map params = [:]) {
|
||||||
sh("git config --add remote.origin.fetch +refs/heads/${distBranch}:refs/remotes/origin/${distBranch}")
|
sh("git config --add remote.origin.fetch +refs/heads/${distBranch}:refs/remotes/origin/${distBranch}")
|
||||||
|
|
||||||
// Update branches
|
// Update branches
|
||||||
sh("git fetch --all")
|
sh('git fetch --all')
|
||||||
|
|
||||||
// Merge currentRef into distBranch and push
|
// Merge currentRef into distBranch and push
|
||||||
sh("git checkout -b '${distBranch}' 'origin/${distBranch}'")
|
sh("git checkout -b '${distBranch}' 'origin/${distBranch}'")
|
||||||
|
@ -40,7 +40,7 @@ def call(Map params = [:]) {
|
||||||
sh("git merge ${currentRef}")
|
sh("git merge ${currentRef}")
|
||||||
|
|
||||||
if (!skipPush) {
|
if (!skipPush) {
|
||||||
sh("git push")
|
sh('git push')
|
||||||
} else {
|
} else {
|
||||||
println("Skipping push. Set skipPush param to 'true' to enable remote repository update.")
|
println("Skipping push. Set skipPush param to 'true' to enable remote repository update.")
|
||||||
}
|
}
|
||||||
|
@ -61,16 +61,23 @@ def call(Map params = [:]) {
|
||||||
|
|
||||||
println("Last version number is '${lastVersionNumber}'")
|
println("Last version number is '${lastVersionNumber}'")
|
||||||
|
|
||||||
def versionNumber = sh(
|
String versionRoot = extractVersionRoot(lastVersionNumber)
|
||||||
|
String versionNumber = ''
|
||||||
|
|
||||||
|
if (versionRoot) {
|
||||||
|
versionNumber = versionRoot
|
||||||
|
} else {
|
||||||
|
versionNumber = sh(
|
||||||
script: "git describe --always ${currentRef}",
|
script: "git describe --always ${currentRef}",
|
||||||
returnStdout: true,
|
returnStdout: true,
|
||||||
).split('/').last().trim()
|
).split('/').last().trim()
|
||||||
|
|
||||||
def isCommitRef = !versionNumber.matches(/^[0-9]+\.[0-9]+\.[0-9]+.*$/)
|
Boolean isCommitRef = !versionNumber.matches(/^[0-9]+\.[0-9]+\.[0-9]+.*$/)
|
||||||
|
|
||||||
if (isCommitRef) {
|
if (isCommitRef) {
|
||||||
versionNumber = "0.0.0-${versionNumber}"
|
versionNumber = "0.0.0-${versionNumber}"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
versionNumber = "${versionNumber}-b${env.BUILD_NUMBER}"
|
versionNumber = "${versionNumber}-b${env.BUILD_NUMBER}"
|
||||||
|
|
||||||
|
@ -91,7 +98,7 @@ def call(Map params = [:]) {
|
||||||
|
|
||||||
// Push tag
|
// Push tag
|
||||||
if (!skipPush) {
|
if (!skipPush) {
|
||||||
sh("git push --tags -f")
|
sh('git push --tags -f')
|
||||||
} else {
|
} else {
|
||||||
println("Skipping push. Set skipPush param to 'true' to enable remote repository update.")
|
println("Skipping push. Set skipPush param to 'true' to enable remote repository update.")
|
||||||
}
|
}
|
||||||
|
@ -118,3 +125,14 @@ def call(Map params = [:]) {
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonCPS
|
||||||
|
String extractVersionRoot(String fullVersion) {
|
||||||
|
Matcher fullVersionMatcher = fullVersion =~ /^([0-9]+\.[0-9]+\.[0-9]+).*$/
|
||||||
|
|
||||||
|
if (!fullVersionMatcher.matches()) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return fullVersionMatcher.group(1)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue