deployer.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:ecs-blue-green-deployment 作者: awslabs 项目源码 文件源码
def get_build_artifact_id(build_id):
    """Get artifact (build.json) from the build project . We are making this as an additional call to get the build.json
    which already contains the new built repository ECR path. We could have consolidated this script and executed in the build
    phase, but as codebuild accepts the input from one source only (scripts and application code are in different sources), thats 
    why an additional call to retrieve build.json from a different build project.

                    Args:
                        build_id - Build ID for codebuild (build phase)
                    Returns:
                        build.json

                    Raises:
                        Exception: Any exception thrown by handler

    """
    codebuild_client = boto3.client('codebuild')
    response = codebuild_client.batch_get_builds(
        ids=[
            str(build_id),
        ]
    )
    for build in response['builds']:
        s3_location = build['artifacts']['location']
        bucketkey = s3_location.split(":")[5]
        bucket = bucketkey.split("/")[0]
        key = bucketkey[bucketkey.find("/") + 1:]
        s3_client = boto3.client('s3', config=Config(signature_version='s3v4'))
        s3_client.download_file(bucket, key, 'downloaded_object')
        zip_ref = zipfile.ZipFile('downloaded_object', 'r')
        zip_ref.extractall('downloaded_folder')
        zip_ref.close()
        with open('downloaded_folder/build.json') as data_file:
            objbuild = json.load(data_file)
        print(objbuild['tag'])
        return objbuild['tag']
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号