My goal is to deploy a Cloud Function using Cloud Build. My cloudbuild.yaml
looks as follows:
steps:
- name: gcr.io/cloud-builders/gcloud
args:
[
'functions', 'deploy', 'func3',
'--region=us-central1',
'--allow-unauthenticated',
'--entry-point=helloWorld',
'--runtime=nodejs8',
'--source=https://source.developers.google.com/projects/XXX/repos/myfunc',
'--trigger-http',
'--service-account=XXX@appspot.gserviceaccount.com'
]
When I submit the build, the following is logged:
Created [https://cloudbuild.googleapis.com/v1/projects/XXX/builds/5ba01de5-b4ad-4489-b4b9-687d3a6fd8fa].
Logs are available at [https://console.cloud.google.com/gcr/builds/5ba01de5-b4ad-4489-b4b9-687d3a6fd8fa?project=YYY].
------------------------------------------------------------------------------------ REMOTE BUILD OUTPUT ------------------------------------------------------------------------------------
starting build "5ba01de5-b4ad-4489-b4b9-687d3a6fd8fa"
FETCHSOURCE
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
ERROR: (gcloud.functions.deploy) unrecognized arguments: --allow-unauthenticated
To search the help text of gcloud commands, run:
gcloud help -- SEARCH_TERMS
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/gcloud" failed: exit status 2
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ERROR: (gcloud.builds.submit) build 5ba01de5-b4ad-4489-b4b9-687d3a6fd8fa completed with status "FAILURE"
As we can see, we fail. If I remove the line which references --allow-unauthenticated
all proceeds correctly. For completeness, here is the working cloudbuild.yaml
.
steps:
- name: gcr.io/cloud-builders/gcloud
args:
[
'functions', 'deploy', 'func3',
'--region=us-central1',
'--entry-point=helloWorld',
'--runtime=nodejs8',
'--source=https://source.developers.google.com/projects/XXX/repos/myfunc',
'--trigger-http',
'--service-account=XXX@appspot.gserviceaccount.com'
]
I have checked the gcloud documentation on gcloud functions deploy
found here and can't see any typos or other trivial errors. I have been assuming that running gcloud
as a Cloud Builder step would be identical to running it manually.
If I run the command manually (including the --allow-unauthenticated
) it works without error. For example, if I run:
#!/bin/bash
gcloud functions deploy func3 \
--region=us-central1 \
--allow-unauthenticated \
--entry-point=helloWorld \
--runtime=nodejs8 \
--source=https://source.developers.google.com/projects/XXX/repos/myfunc \
--trigger-http \
--service-account=XXX@appspot.gserviceaccount.com
... there are no issues.
The core of the question is what might be the issue with the --allow-unauthenticated
option within the context of Cloud Build?