git push后未刷新Google函数源 [英] Google function source not refreshed after git push

查看:55
本文介绍了git push后未刷新Google函数源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Google Cloud函数的源定义为Google Cloud存储库.我更改了函数源代码,提交并通过"git push --all google"将其推入存储库.我在存储库中看到了功能代码的新版本,但是云功能采用了旧版本.

I defined a source of a google cloud function as a google cloud repository. I changed my function source code, commit it and push into the repository by "git push --all google". I see a new version of the function code in the repository but the cloud function takes the old version.

因此,我需要部署函数的新版本.我知道我无法使用控制台做到这一点.当我尝试使用SDK进行部署时,我会收到

So I need to deploy the new version of my function. I understood that I can't do it using console. When I try deploy it using SDK I recieve

gcloud functions deploy json_in_out --runtime nodejs8 --source https://source.developers.google.com/projects/mot_cz/repos/functions/demo/master/paths/json_in_out --trigger-http
ERROR: (gcloud.functions.deploy) ResponseError: status=[400], code=[Bad Request], message=[The request has errors
Problems:
Source repository URL is invalid https://source.developers.google.com/projects/mot_cz/repos/functions/demo/master/paths/json_in_out does not match the expected pattern

推荐答案

将代码推送到Cloud Source Repository并将其部署为Cloud Function的新版本是两件事,就像@Doug Stevenson提到的那样.但是,您可以使用Cloud Build轻松地自动执行此过程.一个基本的实现包括两个步骤:

Pushing your code to Cloud Source Repository and deploying it as a new version of your Cloud Function are two different things, as @Doug Stevenson mentioned. However, you can easily automate this process with Cloud Build. A basic implementation involves 2 steps:

1.使用以下命令将cloudbuild.yaml文件添加到源代码中:

1.Add a cloudbuild.yaml file to your source code with the following:

steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['functions', 'deploy', '[YOUR_DEPLOYED_FUNCTION_NAME]', '[YOUR_FUNCTION_TRIGGER]', '--runtime', '[YOUR_RUNTIME]', '--entry-point', '[YOUR_FUNCTION_NAME_IN_CODE]']

2.在您的开发人员控制台集中创建构建触发器只要您提交到存储库中的特定分支或标签,就可以部署代码.

2.Create a build trigger in your Developer Console set up to deploy your code whenever you commit to a specific branch or tag on your repository.

您会在此处找到一个更复杂的用例涉及测试以备不时之需.

You'll find a more complex use case here that involves testing in case you need it.

这篇关于git push后未刷新Google函数源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆