1

When deploying a simple hello_world app to Google Cloud Functions using gcloud, I get the following error message:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: Build error details not available

It took me quite a while to figure out that this is due to my .cloudignore file:

.cloudignore

# Ignore everything
*

# Except these files:
!main.py
!requirements.txt

What seems to be the problem with this file? And what is a better way achieve what I want, i.e. ignore all files except main.py and requirements.txt?

Any hints are greatly appreciated!

Sebastian
  • 831
  • 2
  • 13
  • 36

2 Answers2

0

The .gcloudignore file follows the same pattern as the .gitignore. Considering that, using only the *, could ended up being a recursively method that would ended up messing the other files that would be excepted.

Considering that, I would recommend you to give a try using the below configuration for your .gcloudignore file - this way, the slash should eliminate this undesired behavior:

# Ignore everything
/*

# Except these files:
!main.py
!requirements.txt

A reminder is that the file needs to be in the same directory that the main.py and requirements.txt file are, so the path works correctly. Otherwise, you will need to set the whole path in the .gcloudignore.

In these below posts from the Community - on specific regarding GCP and other on .gitignore - that might help you, since the syntax for both of them are the same and there are some other options and ideas on how to achieve it.

Let me know if the information helped you!

gso_gabriel
  • 4,199
  • 1
  • 10
  • 22
  • Thanks for taking the time to answer, but unfortunately that's not working, it produces the same unspecific error as above. – Sebastian Feb 25 '20 at 13:13
  • Hi @Sebastian thanks for confirming. Have you checked the above articles that I provided and tried other options? In case none of them solve your case and everything is well configured - files on the same directories, etc. - I would recommend you to reach out directly the [Google's Support](https://cloud.google.com/support) so they can help you investigate what might be affecting your file. Since the `.gcloudignore` file is well configured, it should be working as expected. – gso_gabriel Feb 25 '20 at 13:24
  • Yeah it seems like what's working for .gitignore is not necessarily working for .cloudignore. As I'm not on a premium support plan reaching out to Google's support unfortunately won't work... – Sebastian Feb 25 '20 at 13:46
  • Similar issues here, `gcloud meta list-files-for-upload` correctly handles the `!` rules, but the actual `gcloud functions deploy` mishandles them. – El Yobo Jan 08 '21 at 05:20
0

It seems that there's a bug with gcloud functions handling of .gitignore; gcloud app and gcloud meta list-files-for-upload don't suffer from the same problem, handling the ! rules correctly.

A workaround proposed in this answer to a similar question works for me, explicitly include the . directory e.g. add a rule like this.

!.
El Yobo
  • 14,823
  • 5
  • 60
  • 78