Update version format of artifacts in Jenkins (#1173)

This commit is contained in:
Adam Babik 2018-08-29 12:52:19 +02:00 committed by GitHub
parent 794e799d63
commit 4e386f4097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 16 deletions

View File

@ -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": [