diff --git a/Jenkinsfile b/Jenkinsfile index cbbd435..10aee15 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -library('pipeline-library') +library('pipeline-library@bugfix/durable-task-workaround') pipeline { options { timestamps() } @@ -18,7 +18,7 @@ pipeline { stage('Self Version') { steps { withCredentials([usernamePassword(credentialsId: env.DOCKER_CREDENTIALS, usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) { - sh("docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}") + sh("docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD") } runAutoSemver("rightbrainnetworks/auto-semver:${SELF_SEMVER_TAG}") } @@ -59,6 +59,7 @@ pipeline { agent { docker { image "rightbrainnetworks/auto-semver:${env.VERSION}" + args "--privileged" } } steps @@ -85,7 +86,7 @@ pipeline { // Authenticate & push to DockerHub withCredentials([usernamePassword(credentialsId: env.DOCKER_CREDENTIALS, usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) { sh(""" - docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD} + docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD docker push rightbrainnetworks/auto-semver:${env.VERSION} """) } diff --git a/semver/__init__.py b/semver/__init__.py index da6a610..45a943a 100644 --- a/semver/__init__.py +++ b/semver/__init__.py @@ -1,6 +1,8 @@ import argparse import re import subprocess +import sys +import traceback from enum import IntEnum from semver.utils import get_tag_version from semver.logger import logging, logger, console_logger @@ -111,7 +113,7 @@ class SemVer(object): config_file = file.read() # version repo - logger.debug("Running bumpversion of type: " + self.version_type) + logger.debug("Running bumpversion of type: " + str(self.version_type.name)) bump_version(get_tag_version(), self.version_type) return self @@ -146,20 +148,22 @@ class SemVer(object): return self def main(): + parser = argparse.ArgumentParser(description='Bump Semantic Version.') + parser.add_argument('-n','--no-push', help='Do not try to push', action='store_false', dest='push') + parser.add_argument('-g','--global-user', help='Set git user at a global level, helps in jenkins', action='store_true', dest='global_user') + parser.add_argument('-D', '--debug', help='Sets logging level to DEBUG', action='store_true', dest='debug', default=False) + args = parser.parse_args() + + + if args.debug: + console_logger.setLevel(logging.DEBUG) try: - parser = argparse.ArgumentParser(description='Bump Semantic Version.') - parser.add_argument('-n','--no-push', help='Do not try to push', action='store_false', dest='push') - parser.add_argument('-g','--global-user', help='Set git user at a global level, helps in jenkins', action='store_true', dest='global_user') - parser.add_argument('-D', '--debug', help='Sets logging level to DEBUG', action='store_true', dest='debug', default=False) - args = parser.parse_args() - - - if args.debug: - console_logger.setLevel(logging.DEBUG) - SemVer(global_user=args.global_user).run(push=args.push) except Exception as e: logger.error(e) + if args.debug: + tb = sys.exc_info()[2] + traceback.print_tb(tb) if e == NO_MERGE_FOUND: exit(1) elif e == NOT_MAIN_BRANCH: diff --git a/vars/runAutoSemver.groovy b/vars/runAutoSemver.groovy index 726be84..2f8f825 100644 --- a/vars/runAutoSemver.groovy +++ b/vars/runAutoSemver.groovy @@ -40,6 +40,7 @@ def call(dockerImage = "rightbrainnetworks/auto-semver:latest", debug = false) { break } + env.SEMVER_NEW_VERSION = sh(script: "grep -Po '${regex}' .bumpversion.cfg", returnStdout: true).trim() env.SEMVER_RESOLVED_VERSION = getVersion("-d ${args}") env.VERSION = env.SEMVER_RESOLVED_VERSION