具有云功能的 GCP 云构建未部署最新代码
GCP Cloud build with cloud function doesn't deploy the latest code
我正在尝试使用 Google Cloud Build 设置 CI/CD 管道,以便使用 GitHub 存储库部署 Google Cloud Functions。
我已经设法创建了触发器,每当我将更改推送到 master 分支时,构建就会触发。但是在部署和云函数版本增加后,当我调用云函数时,它仍然执行旧函数。
以下是buildconfig.yaml
steps:
- name: gcr.io/cloud-builders/git
args: ['clone', 'https://github.com/mayuran19/GCP-CloudFunction']
- name: gcr.io/cloud-builders/git
args: ['pull', 'https://github.com/mayuran19/GCP-CloudFunction', 'master']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['functions', 'deploy', 'function-1', '--trigger-http', '--runtime', 'nodejs8', '--entry-point', 'helloWorld']
dir: './'
调试 Cloud Build 具有挑战性,但我认为您缺少正确的部署源。
git clone ...
步骤创建 /workspace/GCP-CloudFunction
但是你gcloud functions deploy ...
来自(默认==/workspace
)。
你需要点gcloud functions deploy ... --source=./GCP-CloudFunction
。 (因为你在 /workspace
; 或 --source=/workspace/GCP-CloudFunction
是明确的)。
一个有用的调试机制是添加例如一个 busybox
步骤 ls -la /workspace
以确保工作区包含您所期望的内容。
我正在尝试使用 Google Cloud Build 设置 CI/CD 管道,以便使用 GitHub 存储库部署 Google Cloud Functions。
我已经设法创建了触发器,每当我将更改推送到 master 分支时,构建就会触发。但是在部署和云函数版本增加后,当我调用云函数时,它仍然执行旧函数。
以下是buildconfig.yaml
steps:
- name: gcr.io/cloud-builders/git
args: ['clone', 'https://github.com/mayuran19/GCP-CloudFunction']
- name: gcr.io/cloud-builders/git
args: ['pull', 'https://github.com/mayuran19/GCP-CloudFunction', 'master']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['functions', 'deploy', 'function-1', '--trigger-http', '--runtime', 'nodejs8', '--entry-point', 'helloWorld']
dir: './'
调试 Cloud Build 具有挑战性,但我认为您缺少正确的部署源。
git clone ...
步骤创建 /workspace/GCP-CloudFunction
但是你gcloud functions deploy ...
来自(默认==/workspace
)。
你需要点gcloud functions deploy ... --source=./GCP-CloudFunction
。 (因为你在 /workspace
; 或 --source=/workspace/GCP-CloudFunction
是明确的)。
一个有用的调试机制是添加例如一个 busybox
步骤 ls -la /workspace
以确保工作区包含您所期望的内容。