Reputation: 2907
I'm trying to use Google Cloud Build
with GitHub to make a CI/CD pipeline.
However I'm struggling with GCB...
Below, a very simple pipeline :
npm install
--> it worksnpm test
--> it worksnpm run css:ALL
(rm
some files + do some minifying stuff) --> seems to workgit
commands --> doesn't workErrors:
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).
cloudbuild.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"']
Do you have any clue?
My objective is simply to git add
all build stuff and push
them back in my branch
.
Thanks
Upvotes: 3
Views: 3424
Reputation: 75715
Cloud Build is a great product!! With some boring things... the .git folder is not copied with the source code.
If you run your cloud build manually, simply add an empty .gcloudignore
file at the root of your repository. Thanks to it, the .git
directory won't be ignored and uploaded with your code.
But this trick doesn't work with trigger. For this, I use this step
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 .
Then you can use git, with a valid and existing .git
dir
Upvotes: 10