-
Is there a way to use an environment variable that was created and exported during the hook execution? My configuration is as follows: before:
hooks:
- ./scripts/extract_version {{ .Major }} {{ .Minor }} # determines the version name based on the major and minor versions, sets and exports VERSION_NAME
builds:
-
main: ./cmd/main.go
ldflags:
- '-X main.versionName={{ .Env.VERSION_NAME }}'
|
Beta Was this translation helpful? Give feedback.
Answered by
caarlos0
Nov 17, 2020
Replies: 2 comments
-
Echoing the result from the script and assigning to a global env variable doesn't seem to work as well: env:
- VERSION_NAME=$(./scripts/extract_version {{ .Major }} {{ .Minor }})
builds:
-
main: ./cmd/main.go
ldflags:
- '-X main.versionName={{ .Env.VERSION_NAME }}' |
Beta Was this translation helpful? Give feedback.
0 replies
-
environment variables do not escape from the hooks, and using Env only accepts plain text values, if you need more complex things you probably need to run something like
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
caarlos0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
environment variables do not escape from the hooks, and using
$()
on yaml doesn't work either.Env only accepts plain text values, if you need more complex things you probably need to run something like