Exemple #1
0
def s2i_inner(context, application, path='.', env="", incremental=False, tag="master", runtime_image=""):
    """Perform an S2I build, that may fail or succeed."""
    # set up the environment option, if supplied
    if context.table:
        envfile = tempfile.NamedTemporaryFile('w')
        for row in context.table:
            envfile.write("%s=%s\n" % (row.get('variable'), row.get('value')))
        envfile.flush()
        env = '-E "%s"' % envfile.name

    context.image = context.config.userdata.get('IMAGE', 'ctf')

    mirror = ""

    if os.getenv("MAVEN_MIRROR_URL", False):
        mirror = "-e 'MAVEN_MIRROR_URL=%s'" % os.getenv("MAVEN_MIRROR_URL")
        
    image_id = "integ-" + context.image
    command = "s2i build --loglevel=5 --pull-policy if-not-present %s --context-dir=%s -r=%s %s %s %s %s %s %s" % (
        mirror, path, tag, env, application, context.image, image_id, "--incremental" if incremental else "",
        "--runtime-image="+runtime_image if runtime_image else ""
    )
    logging.info("Executing new S2I build with the command [%s]..." % command)

    output = _execute(command)
    if output:
        context.config.userdata['s2i_build_log'] = output
    return output
def s2i_inner(context, application, path='.', env="", incremental=False, tag="master"):
    """Perform an S2I build, that may fail or succeed."""
    # set up the environment option, if supplied
    if context.table:
        envfile = tempfile.NamedTemporaryFile('wb')
        for row in context.table:
            envfile.write("%s=%s\n" % (row['variable'], row['value']))
        envfile.flush()
        env = '-E "%s"' % envfile.name

    context.image = context.config.userdata.get('IMAGE', 'ctf')

    mirror = ""

    if os.getenv("CI", False):
        mirror = "-e 'MAVEN_MIRROR_URL=http://nexus-ce.cloud.paas.upshift.redhat.com/repository/maven-public/'"

    image_id = "integ-" + context.image
    command = "s2i build --loglevel=5 --pull-policy if-not-present %s --context-dir=%s -r=%s %s %s %s %s %s" % (
        mirror, path, tag, env, application, context.image, image_id, "--incremental" if incremental else ""
    )
    logging.info("Executing new S2I build...")

    output = _execute(command)
    if output:
        context.config.userdata['s2i_build_log'] = output
    return output