我正在尝试将 Google Cloud Build
与 GitHub 结合使用来制作 CI/CD 管道。
然而,我正在与 GCB 作斗争......
下面是一个非常简单的管道:
npm install
--> 它有效npm test
--> 它有效npm run css:ALL
(rm
一些文件 + 做一些缩小的事情)--> 似乎有效git
命令 --> 不起作用错误:
Step #3: fatal: not a git repository (or any parent up to mount point /)
Step #3: Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
云构建.yaml
steps:
- name: 'gcr.io/cloud-builders/npm'
args: ['install']
# run test
- name: 'gcr.io/cloud-builders/npm'
args: ['test']
# build css files
- name: 'gcr.io/cloud-builders/npm'
args: ['run', 'css:ALL']
# git stuff
- name: 'gcr.io/cloud-builders/git'
args: ['add', '-A']
- name: 'gcr.io/cloud-builders/git'
args: ['commit', '-m', '"some message"']
你有什么线索吗?
我的目标只是git add
所有构建的东西并将它们push
回到我的分支
。
谢谢
最佳答案
Cloud Build 是一款很棒的产品!!有了一些无聊的东西....git 文件夹没有与源代码一起复制。
如果您手动运行云构建,只需在存储库的根目录添加一个空的 .gcloudignore
文件。多亏了它,.git
目录不会被忽略并与您的代码一起上传。
但是这个技巧不适用于触发器。为此,我使用了这一步
steps:
- name: 'gcr.io/cloud-builders/git'
entrypoint: /bin/bash
args:
- -c
- |
# Cloud Build doesn't recover the .git file. Thus checkout the repo for this
git clone --branch $BRANCH_NAME https://github.com/path/to/yourRepo.git /tmp/repo ;
# Copy only the .git file
mv /tmp/repo/.git .
然后你可以使用 git,有一个有效的和现有的 .git
目录
https://stackoverflow.com/questions/60575602/