Ejemplo n.º 1
0
def main():
    get_env('INFRABOX_SERVICE')
    get_env('INFRABOX_VERSION')
    get_env('INFRABOX_ROOT_URL')
    get_env('INFRABOX_GENERAL_DONT_CHECK_CERTIFICATES')
    get_env('INFRABOX_LOCAL_CACHE_ENABLED')
    get_env('INFRABOX_JOB_MAX_OUTPUT_SIZE')
    get_env('INFRABOX_JOB_API_URL')
    get_env('INFRABOX_JOB_GIT_URL')
    get_env('INFRABOX_JOB_MOUNT_DOCKER_SOCKET')
    console = ApiConsole()

    j = None
    try:
        j = RunJob(console)
        j.main()
        j.console.flush()
        j.update_status('finished', message='Successfully finished')
    except Failure as e:
        j.console.header('Failure', show=True)
        j.console.collect(e.message, show=True)
        j.console.flush()
        j.update_status('failure', message=e.message)
    except:
        print_stackdriver()
        if j:
            j.console.header('An error occured', show=True)
            msg = traceback.format_exc()
            j.console.collect(msg, show=True)
            j.console.flush()
            j.update_status('error', message='An error occured')
Ejemplo n.º 2
0
def main():
    get_env('INFRABOX_SERVICE')
    get_env('INFRABOX_VERSION')
    get_env('INFRABOX_DOCKER_REGISTRY_ADMIN_USERNAME')
    get_env('INFRABOX_DOCKER_REGISTRY_ADMIN_PASSWORD')
    get_env('INFRABOX_DOCKER_REGISTRY_URL')
    get_env('INFRABOX_DASHBOARD_URL')
    get_env('INFRABOX_GENERAL_NO_CHECK_CERTIFICATES')
    get_env('INFRABOX_LOCAL_CACHE_ENABLED')
    get_env('INFRABOX_JOB_MAX_OUTPUT_SIZE')
    get_env('INFRABOX_JOB_API_URL')

    parser = argparse.ArgumentParser(description='Process some integers.')
    parser.add_argument('--type', choices=['create', 'run'], help="job type")

    args = parser.parse_args()
    console = ApiConsole()

    j = None
    try:
        j = RunJob(console, args.type)
        j.main()
        j.console.flush()
        j.update_status('finished')
    except Failure as e:
        j.console.collect('## Failure', show=True)
        j.console.collect(e.message, show=True)
        j.console.flush()
        j.update_status('failure')
    except:
        print_stackdriver()
        if j:
            j.console.collect('## An error occured', show=True)
            msg = traceback.format_exc()
            j.console.collect(msg, show=True)
            j.console.flush()
            j.update_status('error')
Ejemplo n.º 3
0
            # c.collect("#Checkout commit", show=True)
            cmd = ['git', 'checkout', '-qf', '-b', 'job', commit]

            # c.collect(' '.join(cmd), show=True)
            output += self.execute(cmd, cwd=mount_repo_dir)

            # c.header("Init submodules", show=True)
            output += self.execute(['git', 'submodule', 'init'],
                                   cwd=mount_repo_dir)
            output += self.execute(['git', 'submodule', 'update'],
                                   cwd=mount_repo_dir)

            return output
        except subprocess.CalledProcessError as e:
            return str(e), 500
        except Exception as e:
            return traceback.format_exc(), 500


def main():  # pragma: no cover
    logger.info('Starting Server')
    http_server = WSGIServer(('0.0.0.0', 8080), app)
    http_server.serve_forever()


if __name__ == "__main__":  # pragma: no cover
    try:
        main()
    except:
        print_stackdriver()