gpt4 book ai didi

git - 将 git 命令与 Google Cloud Builder 结合使用

转载 作者:行者123 更新时间:2023-12-05 09:11:06 24 4
gpt4 key购买 nike

我正在尝试将 Google Cloud Build 与 GitHub 结合使用来制作 CI/CD 管道。然而,我正在与 GCB 作斗争......

下面是一个非常简单的管道:

  1. 运行 npm install --> 它有效
  2. 运行 npm test--> 它有效
  3. 运行 npm run css:ALL(rm 一些文件 + 做一些缩小的事情)--> 似乎有效
  4. 运行一些 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 目录

关于git - 将 git 命令与 Google Cloud Builder 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60575602/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com