I have a NextJS repository in GitLab, which is deployed to Vercel by linking GitLab account to Vercel and selecting that repository.
Initially, all my branches (main
and dev
), and all merge requests were deploying to Vercel (I assume it is default behaviour), but over time I decided that I only want deployments of main
branch to be deployed to Vercel, so I disabled “preview deployments” in Vercel project settings, and disabled dev
branch deployments in vercel.json
file.
And while MRs and dev
branch stopped deploying to Vercel (which is what I wanted), I got an issue - when I push new changes to GitLab’s dev
branch, for some reason after about 25 minutes a new pipeline appears (in GitLab) for dev
branch, instantly in “failed” state, and GitLab sends me an email about failed pipeline, which is annoying.
I am the single maintainer in this repo, no one else has access to the code and/or my Vercel project, so manually-triggered Vercel deployments are off the table (Vercel chatbot asked about it).
No dev
branch deployments are appearing in Vercel Deployments page of this project.
I also have a .gitlab-ci.yml
file (for deployments to different hosting provider), but it does not contain any deployment config regarding Vercel (the issue with failed dev
pipelines occured long before this file was created).
I tried to reconfigure Vercel webhook in GitLab settings to only trigger on main
branch, but this didn’t fix the issue, failed pipelines are still appearing every time I push to dev
branch.
My vercel.json
file contents (it is placed in the root directory of my repo):
vercel.json
{
"crons": [
{
"path": "/api/cron/daily-0000",
"schedule": "0 0 * * *"
},
{
"path": "/api/cron/daily-0900",
"schedule": "0 9 * * *"
}
],
"git": {
"deploymentEnabled": {
"dev": false
}
}
}
My .gitlab-ci.yml
file contents (also placed in the root):
.gitlab-ci.yml
image: alpine
before_script:
- 'which ssh-agent || ( apk add --update openssh-client git )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY_BASE64" | base64 -d)
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
workflow:
rules:
- if: $CI_COMMIT_BRANCH == "main"
variables:
BUILD_PATH: $PROD_BUILD_PATH
OUT_PATH: $PROD_OUT_PATH
when: always
- when: never
stages:
- deploy
production:
stage:
deploy
environment:
name: production
rules:
- if: ($CI_COMMIT_BRANCH == "main") && $BUILD_PATH && $OUT_PATH && $SSH_CONNECT
when: on_success
- when: never
script:
- ssh $SSH_CONNECT "[REDACTED]"
Vercel Git settings:
This is how failed pipelines appear in GitLab UI:
And this is how Vercel webhook configured in GitLab:
I know there’s an option to disable Vercel’s deployments entirely, and move off to GitLab pipelines which would deploy to Vercel manually, but for me this is a last resort option because I’d like to keep more GitLab CI/CD minutes for my other projects.
So, does anybody knows a way to get rid of those “failed” pipelines of dev
branch in GitLab?