【问题标题】:Can Google Cloud Build recurse through directories of artifacts?Google Cloud Build 可以通过工件目录递归吗?
【发布时间】:2019-03-20 14:29:51
【问题描述】:

我的工作区如下所示:

|
|--> web-app
     |
     |--> src
     |--> build
          |
          |--> fonts
          |--> static

我的cloudbuild.json 看起来像这样:

{
    "steps" : [
    {
...
    },
    ],
    "artifacts": {
        "objects": {
            "location": "gs://my_bucket/",
            "paths": [
                "web-app/build/**"
            ]
        }
    }
}

我希望 Google Cloud Build 将递归通过 build/ 文件夹的内容并将文件和目录复制到我的存储桶。相反,它只复制以build/ 目录为根的文件,忽略这些目录并给出有关使用gsutil cp 的-r 选项的警告。

这是构建输出:

...
Artifacts will be uploaded to gs://my_bucket using gsutil cp
web-app/build/**: Uploading path....
Omitting directory "file://web-app/build/fonts". (Did you mean to do cp -r?)
Omitting directory "file://web-app/build/static". (Did you mean to do cp -r?)
Copying file://web-app/build/index.html [Content-Type=text/html]...
Copying file://web-app/build/asset-manifest.json [Content-Type=application/json]...
Copying file://web-app/build/favicon.ico [Content-Type=image/vnd.microsoft.icon]...
Copying file://web-app/build/manifest.json [Content-Type=application/json]...   
Copying file://web-app/build/service-worker.js [Content-Type=application/javascript]...
/ [5/5 files][ 28.4 KiB/ 28.4 KiB] 100% Done                                    
Operation completed over 5 objects/28.4 KiB.                                     
web-app/build/**: 5 matching files uploaded
5 total artifacts uploaded to gs://my_bucket/
Uploading manifest artifacts-d4a2b3e4-97ba-4eb0-b226-e0c914ac4f61.json
Artifact manifest located at gs://my_bucket/artifacts-d4a2b3e4-97ba-4eb0-b226-e0c914ac4f61.json
DONE

文档https://cloud.google.com/storage/docs/gsutil/addlhelp/WildcardNames#directory-by-directory-vs-recursive-wildcards 建议不应该是这种情况。

我想我可以使用gsutil cloud builder,但我怀疑我不需要,而且我在这里做错了。

【问题讨论】:

    标签: google-cloud-build


    【解决方案1】:

    目前 (2018-11) 无法一对一地递归复制工件目录。您最好的选择是在您的 cloudbuild.yaml 文件中使用 gsutil 步骤(正如您已经提到的),类似于:

    steps:
    - ....
    - name: 'gcr.io/cloud-builders/gsutil'
      args: ['-m', 'cp', '-r', 'web-app/build*', 'gs://my_bucket/$BUILD_ID']
    

    【讨论】:

    猜你喜欢
    • 2021-06-16
    • 1970-01-01
    • 2019-09-20
    • 2011-02-01
    • 2020-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多