$VERCEL_GIT_COMMIT_REF is empty

I’m trying to deploy my latest production branch “main”, but is being canceled.

Problem:

  • Current: The VERCEL_GIT_COMMIT_REF environment variable is empty within the bash script executed during the Vercel build process. As a result, the script always evaluates to the else condition, canceling the build.
  • Expected: The VERCEL_GIT_COMMIT_REF environment variable should contain the name of the Git branch associated with the Vercel deployment (e.g., “staging”, “main”). The script should then allow the build to proceed when the branch is “staging” or “main”, and cancel it otherwise.

Code:

#!/bin/bash

echo "VERCEL_GIT_COMMIT_REF: $VERCEL_GIT_COMMIT_REF"

if [[ "$VERCEL_GIT_COMMIT_REF" == "staging" || "$VERCEL_GIT_COMMIT_REF" == "main"]] ; then
  # Proceed with the build
    echo "✅ - Build can proceed"
  exit 1;

else
  # Don't build
  echo "🛑 - Build cancelled"
  exit 0;
fi

Project Information:

  • Framework: Next.js 15.2.0
  • Environment: Vercel
  • Project Settings: The “Ignored Build Step” is set to execute the provided bash script (vercel-bash-script.sh). The specific command being run is bash vercel-bash-script.sh.

Hi, Is this something you are trying for the first time or was working and suddenly broken?

was working yesterday and now is broken

Thanks. We believe it’s due to this issue: Vercel Status - Ignore Build Step triggered erroneously on some builds. We are working on a fix.

2 Likes

This should be fixed now!

It’s, thanks!!

image

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.