Add VERSION_MAYOR parameter to Jenkinsfile and update APP_VERSION calculation
This commit is contained in:
11
Jenkinsfile
vendored
11
Jenkinsfile
vendored
@@ -8,12 +8,12 @@ pipeline {
|
||||
|
||||
parameters {
|
||||
choice(name: 'ENVIRONMENT', choices: ['development', 'main'], description: 'Rama a ejecutar')
|
||||
string(name: 'VERSION_MAYOR', defaultValue: '1', description: 'Componente mayor de versión')
|
||||
}
|
||||
|
||||
environment {
|
||||
REGISTRY = 'dev.aduanasoft.com'
|
||||
IMAGE_NAMESPACE = 'anexo76'
|
||||
VERSION_MAYOR = credentials('version-mayor') // secret text, ej: 1
|
||||
}
|
||||
|
||||
stages {
|
||||
@@ -63,7 +63,7 @@ pipeline {
|
||||
|
||||
if (params.ENVIRONMENT == 'development') {
|
||||
def shortHash = sh(returnStdout: true, script: 'git rev-parse --short=8 HEAD').trim()
|
||||
env.APP_VERSION = "${year}.${month}.${env.VERSION_MAYOR}.${shortHash}"
|
||||
env.APP_VERSION = "${year}.${month}.${params.VERSION_MAYOR}.${shortHash}"
|
||||
} else {
|
||||
def lastTag = sh(returnStdout: true, script: 'git describe --tags --abbrev=0 2>/dev/null || true').trim()
|
||||
def commitCount = lastTag
|
||||
@@ -73,7 +73,7 @@ pipeline {
|
||||
if (commitCount == '0') {
|
||||
commitCount = '1'
|
||||
}
|
||||
env.APP_VERSION = "${year}.${month}.${env.VERSION_MAYOR}.${commitCount}"
|
||||
env.APP_VERSION = "${year}.${month}.${params.VERSION_MAYOR}.${commitCount}"
|
||||
}
|
||||
|
||||
echo "VERSION: ${env.APP_VERSION}"
|
||||
@@ -167,9 +167,4 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
sh 'docker logout "${REGISTRY}" || true'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user