Пример #1
0
 def report_error_to_slack(self, message, ex):
     workspace = environment.get_project_root()
     if workspace:
         if ex:
             message = f'*{workspace}* \n{message} \n ```{str(ex)}```'
         else:
             message = f'*`{workspace}`* {message}'
     slack.send_to_slack(message,
                         username='******')
Пример #2
0
def build(labels=None, build_args=None):
    build_cmd = 'docker build --quiet --pull'
    root = environment.get_project_root()
    if labels:
        for label in labels:
            build_cmd = f'{build_cmd} --label {label}'
    if build_args:
        for arg in build_args:
            build_cmd = f'{build_cmd} --build-arg {arg}'
    return process.run_with_output(f'{build_cmd} {root}')
Пример #3
0
    def report_error_to_slack(self, message, ex):
        workspace = environment.get_project_root()
        if workspace:
            text = f'*{workspace}* \n{message}'

        slack.send(
            text=text,
            snippet=ex,
            icon=":no_entry:",
            username='******')
Пример #4
0
def build(labels=None, build_args=None):
    flags = '--pull'
    #build_local_image_id = 'docker build --quiet --pull'
    root = environment.get_project_root()
    if labels:
        for label in labels:
            flags = f'{flags} --label {label}'
    if build_args:
        for arg in build_args:
            flags = f'{flags} --build-arg {arg}'

    # Build
    log.info(process.run_with_output(f'docker build {flags} {root}'))

    # Rerun build to get a local image id.
    return process.run_with_output(f'docker build --quiet {flags} {root}')
Пример #5
0
Файл: run.py Проект: KTH/evolene
def select_and_run_pipeline():

    logger = logging.getLogger(__name__)
    docker_conf = file_util.get_absolue_path('/docker.conf')
    has_docker_conf = os.path.isfile(docker_conf)
    npm_conf = file_util.get_absolue_path('/npm.conf')
    has_npm_conf = os.path.isfile(npm_conf)

    if has_docker_conf:
        logger.info("Has docker.conf")
        docker_pipeline = DockerDeployPipeline()
        docker_pipeline.run_pipeline()

    if has_npm_conf:
        logger.info("Has npm.conf")
        npm_pipeline = NpmPipeline()
        npm_pipeline.run_pipeline()

    if has_docker_conf is False and has_npm_conf is False:
        workspace = environment.get_project_root()
        text = f'Could not fins any `/docker.conf` or `/npm.conf` in repository *{workspace}*.'
        slack.send(text)
        logger.error(text)
        sys.exit(1)
Пример #6
0
def select_and_run_pipeline():

    logger = logging.getLogger(__name__)
    docker_conf = file_util.get_absolue_path('/docker.conf')
    has_docker_conf = os.path.isfile(docker_conf)
    npm_conf = file_util.get_absolue_path('/npm.conf')
    has_npm_conf = os.path.isfile(npm_conf)

    if has_docker_conf:
        logger.info("Has docker.conf")
        docker_pipeline = DockerDeployPipeline()
        docker_pipeline.run_pipeline()

    if has_npm_conf:
        logger.info("Has npm.conf")
        npm_pipeline = NpmPipeline()
        npm_pipeline.run_pipeline()

    if has_docker_conf is False and has_npm_conf is False:
        workspace = environment.get_project_root()
        message = f'No docker.conf or npm.conf found for project {workspace}'
        slack.send_to_slack(message)
        logger.error(message)
        sys.exit(1)
Пример #7
0
def get_npm_base(data):
    nvm_base = get_nvm_exec_base(data)
    project_path = environment.get_project_root()
    return (f'{nvm_base} npm --prefix {project_path}')
Пример #8
0
def get_project_root():
    return environment.get_project_root().rstrip('/')
Пример #9
0
 def publish(self, data):
     result = nvm.exec_npm_command(data, 'publish --access public',
                                   environment.get_project_root())
     self.log.debug('Result from npm publish was: "%s"', result)