Update self-versioning

This commit is contained in:
Layla 2019-11-22 15:37:53 -05:00
parent 1f0bc75c67
commit fd5d54c4cc

48
Jenkinsfile vendored
View File

@ -15,30 +15,38 @@ pipeline {
}
stages {
//Pulls docker image for self-versioning
stage("Pull Versioning Image")
{
steps
{
withEcr {
sh "docker pull ${DOCKER_REGISTRY}/auto-semver:${SELF_SEMVER_TAG}"
}
}
}
//Runs versioning in docker container
stage('Version') {
agent {
docker {
image "${DOCKER_REGISTRY}/auto-semver:${SELF_SEMVER_TAG}"
}
}
stage('Self Version') {
steps {
// runs the automatic semver tool which will version, & tag,
runAutoSemver()
//Grabs current version
script
{
def docker_image = docker.image("${DOCKER_REGISTRY}/auto-semver:${SELF_SEMVER_TAG}")
docker_image.inside{
def RETURN_STATUS
def regex = '^\\s*current_version\\s*=\\s*\\K[^\\s]+'
env.SEMVER_OLD_VERSION = sh(script: "grep -Po '${regex}' .bumpversion.cfg", returnStdout: true).trim()
RETURN_STATUS = sh(script: "semver -n", returnStatus: true)
echo "Semver Return Status: ${RETURN_STATUS}"
env.SEMVER_STATUS = RETURN_STATUS
switch (RETURN_STATUS) {
case "0":
echo 'Versioned will push after build/test.'
break
case "128":
echo 'Unknown Semver Failure'
sh 'exit 1'
break
default:
echo 'No versioning required.'
break
}
env.SEMVER_NEW_VERSION = sh(script: "grep -Po '${regex}' .bumpversion.cfg", returnStdout: true).trim()
env.SEMVER_RESOLVED_VERSION = getVersion('-d')
env.VERSION = getVersion('-d')
}
}