vercel command is used to deploy Vercel Projects and can be used from either the root of the Vercel Project directory or by providing a path to it.
vercel --cwd [path-to-project]
vercel deploy --prebuilt
stdout is always the Deployment URL.
vercel > deployment-url.txt
In the following example, you create a bash script that you include in your CI/CD workflow. The goal is to have all preview deployments be aliased to a custom domain so that developers can bookmark the preview deployment URL.
# save stdout and stderr to files vc deploy >deployment-url.txt 2>error.txt # check the exit code code=$? if [ $code -eq 0 ]; then # Now you can use the deployment url from stdout for the next step of your workflow deploymentUrl=`cat deployment-url.txt` vc alias $deploymentUrl my-custom-domain.com else # Handle the error errorMessage=`cat error.txt` echo "There was an error: $errorMessage" fi
If you need to check for errors when the command is executed such as in a CI/CD workflow,
stderr. If the exit code is anything other than
0, an error has occurred. The
following example demonstrates a script that checks if the exit code is not equal to 0:
# save stdout and stderr to files vc deploy >deployment-url.txt 2>error.txt # check the exit code code=$? if [ $code -eq 0 ]; then # Now you can use the deployment url from stdout for the next step of your workflow deploymentUrl=`cat deployment-url.txt` echo $deploymentUrl else # Handle the error errorMessage=`cat error.txt` echo "There was an error: $errorMessage" fi
These are options that only apply to the
vercel command, therefore, more information is provided.
--build-env option, shorthand
-b, can be used to provide environment variables to the build step.
vercel --build-env KEY1=value1 --build-env KEY2=value2
--yes option can be used to skip questions you are asked when setting up a new Vercel Project.
The questions will be answered with the provided defaults, inferred from
vercel.json and the folder name.
--env option, shorthand
-e, can be used to provide Environment Variables at Runtime.
vercel --env KEY1=value1 --env KEY2=value2
--nameoption has been deprecated in favor of Vercel Project Linking, which allows you to link a Vercel Project to your local codebase when you run
--name option, shorthand
-n, can be used to provide a Vercel Project name for a deployment.
vercel --name foo
--prod option can be used to create a deployment for a production domain specified in the Vercel Project dashboard.
--public option can be used to ensures the source code is publicly available at the
vercel --regions sfo1
--no-wait option does not wait for a deployment to finish before exiting from the
--force option, shorthand
-f, is used to force a new deployment without the build cache.
--with-cache option is used to retain the build cache when using
vercel --force --with-cache
--archive option compresses the deployment code into a single file before uploading it. The only currently supported format is "tgz".
The following global options can be passed when using the
vercel deploy command:
For more information on global options and their usage, refer to the options section.