runner: "Unrecognized named-value: 'env'. Located at position 1 within expression" when used in reusable workflow jobs
Describe the bug Usage of env in workflow that uses reusable workflow generates “Unrecognized named-value: ‘env’. Located at position 1 within expression”
To Reproduce Use the following yml:
name: Test Workflow
on:
push:
env:
SOMETHING: 1000
test:
name: call workflow
uses: ./.github/workflows/callee.yml
secrets: inherit
with:
run_url: "{run_url}"
message: ${{ env.SOMETHING }}
Expected behavior env.SOMETHING is usable and can be passed into reusable workflow
Actual behavior
The workflow is not valid. .github/workflows/create-branch.yml (Line: #, Col: ##): Unrecognized named-value: 'env'. Located at position 1 within expression: env.SOMETHING
Runner Version and Platform
Version of your runner?
OS of the machine running the runner? ubuntu-latest
What’s not working?
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 85
- Comments: 37
Commits related to this issue
- [GHA] Adjust workflows to work with pull requests - use public qodana linter for PRs - do not collect and analyze coverage Coverage analysis suppressed in the _coverage.yml instead of main workflow ... — committed to Camelcade/Perl5-IDEA by hurricup a year ago
- [GHA] Adjust workflows to work with pull requests - use public qodana linter for PRs - do not collect and analyze coverage Coverage analysis suppressed in the _coverage.yml instead of main workflow ... — committed to Camelcade/Perl5-IDEA by hurricup a year ago
- [GHA] Adjust workflows to work with pull requests - use public qodana linter for PRs - do not collect and analyze coverage Coverage analysis suppressed in the _coverage.yml instead of main workflow ... — committed to Camelcade/Perl5-IDEA by hurricup a year ago
- `env` at workflow top level is still broken[1], working around it [1] https://github.com/actions/runner/issues/2372 — committed to apache/logging-parent by vy 10 months ago
I guess I wasted 30 mins of my life and ended up here like the rest of us
+1. Get this fixed github, cmon.
I’m having the same issue
@whsalazar the question is what the reason behind this? And if there is no real reason, would be nice to have it.
The solution is to pass the environment variables as the output of a job:
hello! if i can help u. or something need to do.say step b step
just use
vars
instead ofenv
Still doesn’t work. It’s weird.
2023 and still have the same issue
You can use
${{ vars.MY_VAR }}
stored in the repository instead ofenv
when referencing in reusable workflows. Not perfect, but it worksYes…
you forgot to put the
s
The env context is not available from jobs.<job_id>.with.<with_id>. See https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/contexts#context-availability
Hi GHA folks: Any update on providing this capability? Some of us are using workarounds, including the one suggested by @nicole0707. But, having this feature will make the intent very clear and clean.
Having the same issue . When it’s going to fix? any work around of it?
I have the same issue, there is workaround to use
$GITHUB_OUTPUT
instead.