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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With