16

I ran into a bigger problem and am really desperate and downturned because I cannot figure out a solution.

I am using a Notebook with Linux Debian 9, git for version control, bitbucket as source code repository service and netlify as production deployment service. Besides I am using Contentful CMS API to quickly add new pages.

Yesterday I deleted my repository on bitbucket and pushed the same one with some slight changes freshly from my local "backup" repo to bitbucket today.

Pushing is just working fine. However, I cannot deploy with Netlify anymore... I keep getting the following error:

10:21:02 PM: Starting to prepare the repo for build 10:21:05 PM: git ref refs/heads/master does not exist or you do not have permission 10:21:05 PM: Failing build: Failed to prepare repo 10:21:05 PM: failed during stage 'preparing repo': git ref refs/heads/master does not exist 10:21:05 PM: Finished processing build request in 12.473521036s

When I push, Netlify tries to build, so there is a connection between Bitbucket and Netlify but the build fails. In my local repo refs/heads/master does exist. git branch -a also tells me that my branch is master. On bitbucket the branch is also master.

Why won't Netlify build? Is there a problem with the API ID? The API ID might only be valid for the repo I deleted yesterday but then Netlify and Bitbucket wouldn't be able to communicate, right?

I didn't make any changes in Netlify. The only thing I changed is the Repository on Bitbucket. I am assuming that I broke the API ID. I cannot change the API on Netlify, though. Also, there doesn't seem to be any option on Bitbucket for adding it.

And I don't even know if that is the problem. If it is, the only 2 options I have got is deleting the Netlify website and create a new one, choosing the bitbucket repo and granting Netlify full access to it.

But what happens if it won't deploy? Then it is offline and I won't be able to bring it up again.

Can anyone help me? What am I supposed to do? Let me know if you need any additional information.

timunix
  • 609
  • 6
  • 19

1 Answers1

49

Try the following:

  • Go to Netlify and choose the existing site
  • Click on Settings
  • In the left menu select Build and Deploy
  • Under Deploy Settings click on the Edit Settings button
  • Then next to Repository, click on Link to a different repository enter image description here
  • Select Bitbucket and the new repository

This should update your API ID for the new Repository. You may need to manually trigger a deploy after this step.

talves
  • 13,993
  • 5
  • 40
  • 63
  • Thanks a bunch! That got rid of the error mentioned above but triggered a new one: 9:48:03 AM: Error running command: Build script returned non-zero exit code: 10 9:48:03 AM: Failing build: Failed to build site 9:48:03 AM: failed during stage 'building site': Build script returned non-zero exit code: 10 – timunix Dec 08 '18 at 08:53
  • 1
    @timunix most of the time I just run the build command local and there is enough to debug why the build is failing. In most cases, if a build fails on netlify deploy, it will fail on local build also. – talves Dec 08 '18 at 15:17
  • You are right, the build failed locally too. The problem was that my repository had a folder called "website20" and in this folder were the actual files. When I tried to deploy, Netlify could not find the Gemfile because it only saw the folder "website20" but could not look inside. I changed the folder structure locally, pushed and then the deploy worked just fine. Thanks again! – timunix Dec 09 '18 at 19:38
  • A lot of Netlify users need to make sure to include the build command in local testing before pushing code to their repo. Saves tons of time chasing errors they would have caught sooner. Glad it helped. – talves Dec 09 '18 at 20:30