exec icon indicating copy to clipboard operation
exec copied to clipboard

Passing enviornment variables to the script

Open nabebin opened this issue 3 years ago • 4 comments

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}"
}

nabebin avatar Apr 16 '21 13:04 nabebin

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! 😣)

konradekk avatar May 25 '21 23:05 konradekk

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.

gliech avatar Aug 21 '21 22:08 gliech

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… 😅

konradekk avatar Oct 17 '21 11:10 konradekk

@pvdlg bumping!

konradekk avatar Oct 29 '21 23:10 konradekk