Deploy Gitlab staging branch via CLI

I’m sure this has been covered because I’ve read a lot of stuff. Some of it seems to contradict other stuff (highly likely I’ve misunderstood) and I am still confused.

I have successfully deployed my site, https://leo-learning-studio.netlify.app/ (main branch), to Netlify using netlify-cli. What I want is to set up a staging version based on the staging branch in my repo. I tried various iterations using the --alias flag though as I now understand it this is not what that flag does. I’ve moved on to creating a new Netlify site, https://leo-learning-staging-studio.netlify.app/, set up almost identically to the main version which works fine. I manually init’ed a new site, updated my $NETLIFY_SITE_ID with the one produced in the init. Added the new deploy key to the repository. However, when my pipeline runs it fails with the error, “Site not found”. Can anyone give me any idea of what I am doing wrong? Thanks.

Hey @Colette_Wilson_Wyatt, it might be a case of running netlify unlink and netlify link and linking up to the site you’re looking to work on.

The command list is a super useful reference too!

Hey thanks,

I have done this multiple times already with no success. I also have read that the --site flag is specifically for circumnavigate linking as I understand it though I could be wrong.

For anyone experiencing the same problem. The reason my deploy was failing was because the environment specific variables set in the Gitlab UI were not pulling through because my branch was not protected. Took me longer than I’d like to admit to figure this out, hopefully it can save you some time.

2 Likes

Thanks so much for closing the loop!

1 Like