Why are my branch specific variables and domains not linked to my CLI deployments?

How to link CLI deployments to the correct branch for use with custom environments and branch specific domains and environment variables
Last updated on December 20, 2024
Environment VariablesBuild, Deployment & Git

If you’re using the Vercel CLI to create deployments, either from a local environment or within your CI/CD pipeline, you may see that branch specific custom environments, including variables and domains, are not being correctly linked.

The most common reason for this is because the git meta information is missing and so the deployment on Vercel is not linked to a specific branch and instead defaults to HEAD.

To resolve this, you can make sure the correct meta information is passed through with the vercel deploy command by making use of the --meta or -m option.

This is available for GitHub, GitLab and Bitbucket with the following git related parameters:

“meta”:
{
“githubCommitAuthorName”: “Author Name”,
“githubCommitMessage”: “Commit Message”,
“githubCommitOrg”: “your-github-organization”,
“githubCommitRef”: “feature/branch-name”,
“githubCommitRepo”: “repository-name”,
“githubCommitSha”: “3A614DC”,
“githubDeployment”: “1”,
“githubOrg”: “your-github-organization”,
“githubRepo”: “repository-name”,
“githubCommitAuthorLogin”: “Username”
}

The above example uses GitHub, but this can be replaced with either GitLab or Bitbucket depending on which provider you are using.

When using the --meta option, please note that you must always include one of githubDeployment=“1", gitlabDeployment="1" or bitbucketDeployment="1" to confirm which of those three git providers you are using. This is needed as well as the parameter you are passing so the information can be correctly added to the deployment on the Vercel platform.

An example of using this to add the branch information is shown below:

vercel deploy -m githubDeployment=“1" -m githubCommitRef=“feature/branch-name”

Couldn't find the guide you need?