exec
exec copied to clipboard
Passing enviornment variables to the script
My "publishCmd" script needs environment variables to be set to run properly. How could I pass them to the script?
I've tried the code below but with no success:
"@semantic-release/exec",
{
"publishCmd": "node ./scripts/publish.js ${env.CI_ENVIRONMENT_VARIABLE}"
}
see #117 for a possible solution; endorse that if it’s what you needed.
(it’s taking sooooo much time to assess that by the author, though! 😣)
I had the same problem, and after some trial and error I noticed that I could simply access the environment through the process object. Adapting your example, it would look like this:
"@semantic-release/exec",
{
"publishCmd": "node ./scripts/publish.js ${process.env.CI_ENVIRONMENT_VARIABLE}"
}
It would still be nice to see #117 merged into master though.
this should work if you use release.config.js
(and through cli in a natural manner). 🤔
the method you’ve indicated should almost certainly fail (as far as i remember) if you’ve settled for .releaserc
or package.json
(release
key) for handling your configuration. i’m pretty sure this was the reason why i’d stumbled upon this in a first place… 😅
@pvdlg bumping!