Should the `SEED_BRANCH` environment variable be t...
# seed
r
Should the
SEED_BRANCH
environment variable be the source or target branch for an auto deployed gitlab MR? I had expected it to be the source branch but it seems to be "master" when I echo it in the post-deploy phase - is this a bug or a feature? 🐛/🦋
Any thoughts @Frank?
a
@Robert Chandler I don't use gitlab, but have you tried echoing out the
SEED_STAGE_BRANCH
environment variable to see if that's the branch you expect it to be? According to the docs: https://seed.run/docs/adding-a-build-spec#build-environment-variables that envvar should contain the branch name that's being auto-deployed from:
• The name of the git branch the stage is auto-deployed from. If the stage is not auto-deployed, the value is not defined.
And actually reading the docs for
SEED_BRANCH
For PR stages, this is the branch the PR was submitted to.
I'm fairly certain
SEED_STAGE_BRANCH
will work for you.
r
Because I'm deploying from a PR rather than a feature branch the
SEED_STAGE_BRANCH
is undefined. After re-reading the docs it does seem like it is indeed a features that the
SEED_BRANCH
env var is the target branch not the source branch. In which case it seems like it's not possible to get the source branch name for an auto-deployed PR branch . Other options include triggering the deployment manually from gitlab ci, using the commit id or switching to github
f
Hey guys, sorry about the delay getting to this. @Robert Chandler we just added two more build environment variables:
Copy code
SEED_PULL_REQUEST_SOURCE_BRANCH
SEED_PULL_REQUEST_TARGET_BRANCH
They hold the value for the source and target branch names.
r
Brilliant, thank you!
I'm assuming this isn't yet deployed as I just tried it out and the variables are empty
f
Hey @Robert Chandler, those two environment variables should've already been deployed.
Are they showing up in your recent builds?
r
I just saw they were working in our newest PR branch, I'm now checking older PR branches
Ok, it seems the env vars are only there for new PR branches/new commits. This is fine 🙂