BUG FIX: Expand branch environment variables

Small patch to fix a problem with branch ref environment variables not being expanded.