I have an environment variable for my CodeBuild environment, DiscordWebhook
. This contains a URL as plaintext. I am trying to run the sed
command as below. This is specified in the BuildSpec.yml
file.
sed -i 's/discordWebhookAddressLocal/${DiscordWebhook}/g' scripts.js
Obviously, this just replaces all instances of discordWebhookAddressLocal
with "${DiscordWebhook}". I have tried some other methods such as using an alias
command, but when I try to execute the alias, CodeBuild fails saying that the command could not be found.
How can I specify an environment variable into the command?
This probably happens because you are using single quotes. Normally you would use double quotes to resolve the variables: