I have a site and different sub-branches which all of them integrated to Github
CI-CD pipeline to auto-build/deploy. The site (with branches) runs almost for 3
years. Recently I got persistent error on every builds. The build can’t
complete the task and give similar error every time:
5:12:01 PM: Build ready to start
5:12:03 PM: build-image version: d84c79427e8f83c1ba17bcdd7b3fe38059376b68
5:12:03 PM: build-image tag: v3.6.1
5:12:03 PM: buildbot version: 28b3358b4c94ec0a3a8c81b155535f3f8c2745f1
5:12:03 PM: Fetching cached dependencies
5:12:03 PM: Starting to download cache of 287.0MB
5:12:06 PM: Finished downloading cache in 3.066177938s
5:12:06 PM: Starting to extract cache
5:12:15 PM: Finished extracting cache in 9.140952106s
5:12:15 PM: Finished fetching cache in 12.308016169s
5:12:15 PM: Starting to prepare the repo for build
5:12:16 PM: Preparing Git Reference refs/heads/tech
5:12:20 PM: Error fetching branch: https://github.com/SerhatTeker/serhatteker.com refs/heads/tech
5:12:20 PM: Failing build: Failed to prepare repo
5:12:20 PM: Failed during stage 'preparing repo': exit status 1
5:12:20 PM: Finished processing build request in 17.17616741s
OK you can’t fetch the branch but why? You already have access. Can’t see the
detail.
After Clear Cache and Deploy build works and deploys the site.
Btw I read the below guide but none of the options below apply to my site since I have a HUGO
builder therefore I don’t have any node_modules nor package.json nor yarn.lock.
Sorry for the delayed response on our end. I have sent this question over to another member of my team so that they can have a look. If you have made any additional progress in the past 11 days, please include that here!
I am hoping to have some next steps for you soon, and thanks again for your patience.
Thank you for your answer.
However I believe private repo access is not the issue -at least on my side. Since:
I already followed and added SSH Deploy Key long ago, as described in the link you shared.
Key added date: 13.01.2021. Also as you can see in the below screenshot it was already used before.
I can deploy the site and got no error after Clear Cache and Deploy.
If netlify couldn’t have accessed to my private repo, it shouldn’t be deployed after Clear Cache and Deploy as well?
P.S:
I added new SSH Deploy Key today (19.02.2021), and deleted old one. But still same error like above. You can see it was used after Clear Cache and Deploy. Screenshot:
I think that the problem Luke quotes is not about repo access, @serhat . It’s a problem in your codebase around submodule references, which you’ll need to fix.
The article points out the silver lining behind below 3:
either the tag in the submodule was never pushed
Submodule or superproject doesn’t have any tag.
or (since it is working from other sources) XXX does not have access to the submodule - private dependencies
We saw that netlify already access to the private repo.
or it has some cached version of that submodule
Yes, it seems this is our cause. After “Clear cache and deploy” build works.
I don’t mind and can use autoclear cache solution. However I tried below one before opening this topic, but it doesn’t clear the cache`.
For instance you can look at this deploy:- 6037e159e814fd1a435f6edd. Deploy 6037e2390b77810008db2ecd failed after it.
Hi, @serhat. I show the build command used in that deploy here:
Was this:
9:41:55 AM: Different build command detected, going to use the one specified in the Netlify configuration file: 'git submodule update --force --init --recursive --depth=1 && hugo --gc --minify' versus 'hugo --gc --minify' in the Netlify UI
So the manual cache clearing wasn’t attempted. Would you be willing to test the rm -rf $NETLIFY_CACHE_DIR/* addition again? I don’t think it actually occurred in your previous test.
After very long line of permission errors (about 85K) the build failed:
...
...
5:13:52 PM: rm: cannot remove '/var/backups': Permission denied
5:13:52 PM: Caching artifacts
5:13:52 PM: chmod: cannot access '/opt/buildhome/.gimme_cache': No such file or directory
5:13:52 PM: mkdir: cannot create directory ‘/opt/build/cache/node_version’: No such file or directory
5:13:52 PM: mv: cannot stat '/opt/buildhome/.nvm/versions/node/*': No such file or directory
5:13:52 PM: mkdir: cannot create directory ‘/opt/build/cache/ruby_version’: No such file or directory
5:13:52 PM: mv: cannot stat '/opt/buildhome/.rvm/rubies/ruby-2.3.6': No such file or directory
5:13:52 PM: Cached ruby version 2.3.6
5:13:52 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:13:52 PM: Failing build: Failed to build site
5:13:52 PM: Finished processing build request in 9m26.699202884s
Hi Serhat! Sorry - that should have worked but in fact that $NETLIFY_CACHE_DIR is somehow not set during your build so you are removing the root directory - including your just-built site! So even if it worked better - didn’t error out - your site would not deploy in a useful way.
We did some testing and this should work better as a build command for you:
I have integrated the new command — rm -rf /opt/build/cache, however unfortunately didn’t work. There is no permission error this time but the new build loaded cache again.
Failed build can be found:
First implementation of new rm can be found at this build:
Well, I guess we can stop trying to hack that into place. Sorry we didn’t find a good solution for you.
Our dev team is working on an improvement to our webhooks to allow cache clearing as part of them, which will be your solution once it is shipped. I do not have a firm ETA on this work, but will report back here when it is ready.