Update version format of artifacts in Jenkins (#1173)
This commit is contained in:
parent
794e799d63
commit
4e386f4097
|
@ -1,20 +1,5 @@
|
||||||
#!/usr/bin/env groovy
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
@NonCPS
|
|
||||||
def getVersion(branch, sha, buildNumber) {
|
|
||||||
version = branch.replaceAll(/\//, '-')
|
|
||||||
|
|
||||||
if (sha?.trim()) {
|
|
||||||
version = version + '-g' + sha
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buildNumber?.trim()) {
|
|
||||||
version = version + '-' + buildNumber
|
|
||||||
}
|
|
||||||
|
|
||||||
return version
|
|
||||||
}
|
|
||||||
|
|
||||||
node('linux') {
|
node('linux') {
|
||||||
env.GOPATH = "${env.WORKSPACE}"
|
env.GOPATH = "${env.WORKSPACE}"
|
||||||
env.PATH = "${env.PATH}:${env.GOPATH}/bin"
|
env.PATH = "${env.PATH}:${env.GOPATH}/bin"
|
||||||
|
@ -87,7 +72,10 @@ node('linux') {
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
dir(cloneDir) {
|
dir(cloneDir) {
|
||||||
// For branch builds, replace the old artifact. For develop keep all of them.
|
// For branch builds, replace the old artifact. For develop keep all of them.
|
||||||
def version = gitBranch == 'develop' ? getVersion(gitBranch, gitShortSHA, '') : getVersion(gitBranch, gitShortSHA, env.BUILD_ID)
|
def version = sh(
|
||||||
|
script: "git describe --exact-match --tag 2>/dev/null || git describe --always",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
def server = Artifactory.server 'artifacts'
|
def server = Artifactory.server 'artifacts'
|
||||||
def uploadSpec = """{
|
def uploadSpec = """{
|
||||||
"files": [
|
"files": [
|
||||||
|
|
Loading…
Reference in New Issue