My workspace looks like this:
|
|--> web-app
|
|--> src
|--> build
|
|--> fonts
|--> static
My cloudbuild.json
looks like this:
{
"steps" : [
{
...
},
],
"artifacts": {
"objects": {
"location": "gs://my_bucket/",
"paths": [
"web-app/build/**"
]
}
}
}
What I'm hoping for is that Google Cloud Build will recurse through the contents of the build/
folder and copy the files & directories to my storage bucket. Instead it only copies the files that are rooted in the build/
directory, ignores the directories and gives a warning about using the -r
option of gsutil cp
.
Here is the build output:
...
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
The documentation https://cloud.google.com/storage/docs/gsutil/addlhelp/WildcardNames#directory-by-directory-vs-recursive-wildcards suggests that this shouldn't be the case.
I guess I could use the gsutil cloud builder but my suspicion is that I don't need to and that I'm doing something wrong here.
Cloud Build is a service that executes your builds on Google Cloud. Cloud Build can import source code from a variety of repositories or cloud storage spaces, execute a build to your specifications, and produce artifacts such as Docker containers or Java archives.
Google Cloud CI/CD provides various tools for continuous integration and deployment and integrates seamlessly with third-party solutions. Google Cloud Build and Google Cloud Run are two Google Cloud services that use pipelines to automate builds and deployments.
In the Google Cloud console, go to the Cloud Storage Buckets page. Navigate to the bucket. Click on Create folder to create an empty new folder, or Upload folder to upload an existing folder.
We recommend using Artifact Registry for storing build artifacts. Artifact Registry is a Google Cloud product that you can integrate with Cloud Build to securely store and manage your artifacts in private or public repositories.
There's currently (2018-11) no way to copy an artifacts directory recursively one-to-one. Your best bet is to use a gsutil step in your cloudbuild.yaml file (as you mentioned already), similar to:
steps:
- ....
- name: 'gcr.io/cloud-builders/gsutil'
args: ['-m', 'cp', '-r', 'web-app/build*', 'gs://my_bucket/$BUILD_ID']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With