-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing custom template as env var or parameter causes JSON error #219
Comments
Are you able to show a small snippet from the
step? I'm curious what the JSON being echo'd to the environment variable looks like. |
Sure, this is what I was using for the POC:
|
@chrisbruford chrisbruford The reason passing the text in directly would work but an env var would not, is because of how the parameter is utilized as an env var. It is expecting a string and not evaluating the environment variable. We inject the parameter as an environment variable:
This parameter is expecting a string. In order to accept an environment variable, we would need to first evaluate the value in I believe however the use-case you are attempting to solve for can be achieved with what we are calling "dynamic templates". Could you tell me if this would work? |
Thanks @KyleTryon Dynamic Templates worked perfectly - barely any change required at all; just use the env var param directly in I wonder if the naming or documentation could be tidied up a bit to better signpost the differences between the two? to me "custom" is really Just my 2 cents - great orb, and thanks for pointing me in the right direction! |
In my case doesn't work, I had to download the notify script, export all required variables and call that script in the same step. |
Also if you have a json template that contains a " which is a double quote scaped in a json file. The slack files becase there is one step that replaces all the " to " so it my double quotes scpaed turns into \". The you replace all " to " again, so the final output of my double quote scaped truns into just a \ |
I also ran into this issue (i.g., I'm including the git commit message in the Slack template and messages with double quotes would cause the Slack notification to fail to send) and ended up having to just strip out double quotes from the content. |
Hi @chrisbruford, I'm glad that the dynamic templates worked for you! I agree that the documentation could be more explicit about the difference between the @xavidop Are you still having this issue? If so, could you please post a snippet of your template? It sounds like @schellj's solution might work for you too. |
I'll close this issue due to staleness. @xavidop, please open another issue if you are still having trouble with your template. |
Orb version: 4.1.3
What happened:
Passing valid JSON directly into the
custom
parameter works as expected; however when putting said JSON into an environment variable or parameter it causes a parse error.I've tried:
Passing the JSON directly ✅
Passing the JSON as an env var ❌
Passing the JSON as a string parameter ❌
Passing the JSON as an env var parameter ❌
Here's how I'm setting and calling (the node call returns the JSON in question):
Here's the command I've setup:
The "Show template" step runs as expected and outputs the valid JSON
here's the output from the slack/notify step:
Expected behavior:
The slack/notify command should be able to receive env vars and params in the custom parameter
The text was updated successfully, but these errors were encountered: