コード例 #1
0
ファイル: request_build.py プロジェクト: azlat/TESTSEC
def run_build(project_name, image_project, build_steps, credentials, tag):
    """Execute build on cloud build."""
    build_body = {
        'steps': build_steps,
        'timeout': str(build_lib.BUILD_TIMEOUT) + 's',
        'options': {
            'machineType': 'N1_HIGHCPU_32'
        },
        'logsBucket': build_project.GCB_LOGS_BUCKET,
        'tags': [
            project_name + '-' + tag,
        ],
        'queueTtl': str(QUEUE_TTL_SECONDS) + 's',
    }

    cloudbuild = build('cloudbuild',
                       'v1',
                       credentials=credentials,
                       cache_discovery=False)
    build_info = cloudbuild.projects().builds().create(
        projectId=image_project, body=build_body).execute()
    build_id = build_info['metadata']['build']['id']

    update_build_history(project_name, build_id, tag)
    logging.info('Build ID: %s', build_id)
    logging.info('Logs: %s',
                 build_project.get_logs_url(build_id, image_project))
コード例 #2
0
def request_build(event, context):
    """Entry point for cloud function to request builds."""
    del context  #unused
    if 'data' in event:
        project_name = base64.b64decode(event['data']).decode('utf-8')
    else:
        logging.error('Project name missing from payload')
        sys.exit(1)

    credentials, image_project = google.auth.default()
    build_steps = get_build_steps(project_name, image_project, BASE_PROJECT)

    build_body = {
        'steps': build_steps,
        'timeout': str(build_lib.BUILD_TIMEOUT) + 's',
        'options': {
            'machineType': 'N1_HIGHCPU_32'
        },
        'tags': [
            project_name + '-fuzzing',
        ],
    }

    cloudbuild = build('cloudbuild',
                       'v1',
                       credentials=credentials,
                       cache_discovery=False)
    build_info = cloudbuild.projects().builds().create(
        projectId=image_project, body=build_body).execute()
    build_id = build_info['metadata']['build']['id']

    logging.info('Build ID: %s', build_id)
    logging.info('Logs: %s',
                 build_project.get_logs_url(build_id, image_project))