【问题标题】:Append timestamp to a S3 bucket folder in builspec.yaml file将时间戳附加到 buildspec.yml 文件中的 S3 存储桶文件夹
【发布时间】:2020-08-21 21:16:54
【问题描述】:

我是 YAML 文件的新手。我想每次都将时间戳附加到 S3 存储桶文件夹,以便每个构建都是唯一的。在 post_build 中,我将时间戳附加到 S3 存储桶,如下所示。当触发代码管道时,所有文件都存储到 S3 存储桶内部文件夹,但没有生成带有时间戳的文件夹。 s3://${S3_BUCKET}/Inhouse/${'date'}

Version: 0.2
env:
    variables:
        S3_BUCKET: Inhouse-market-dev
phases:
    install:
        runtime-versions:
            nodejs: 10
        commands:
            - npm install
            - npm install -g @angular/cli
    build:
        commands:
            - echo Build started on `date`
    post_build:
         commands:
            - aws s3 cp . s3://${S3_BUCKET}/Inhouse/${'date'} --recursive --acl public-read --cache-control "max-age=${CACHE_CONTROL}"
            - echo Build completed on `date`

【问题讨论】:

    标签: amazon-web-services yaml aws-codepipeline


    【解决方案1】:

    我认为您对${'date'} 的使用不正确。我建议尝试以下方法来实际获取 unix 时间戳:

        post_build:
             commands:
                - current_timestamp=$(date +"%s")
                - aws s3 cp . s3://${S3_BUCKET}/Inhouse/${current_timestamp} --recursive --acl public-read --cache-control "max-age=${CACHE_CONTROL}"
                - echo Build completed on `date` which is ${current_timestamp}
    

    【讨论】:

    • 嘿马辛。有效。我弄错了谢谢你的帮助。
    • @RaghuRam 很高兴听到这个消息。如果是这样,将不胜感激接受答案。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-02
    • 2015-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-19
    相关资源
    最近更新 更多