Variable type lost when defining outputs for a job #27921
|
Hello, Job 1: I run a python script which has the following code: I need this variable in another Job, Followed (https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs) Job 2: Printing the above variable I set: The strings get converted into variables |
Replies: 1 comment 1 reply
|
That's because you run the variable through the shell without escaping in the For the job that creates the output, you could simply use the import json
# set output_list somehow
print(f'::set-output name=test::{json.dumps(output_list)}')And you even get a simpler workflow as a bonus. 😸 For the receiving job it depends what you actually want to do with it. If you need to insert it directly into a shell command (and not via env or something), you could even run the JSON through |



That's because you run the variable through the shell without escaping in the
echocommand. The shell then interprets the"as shell syntax, and in the end it's gone from the output.For the job that creates the output, you could simply use the
set-outputcommand directly from Python, so it doesn't go through the shell:And you even get a simpler workflow as a bonus. 😸
For the receiving job it depends what you actually want to do with it. If you need to insert it directly into a shell command (and not via env or something), you could even run the JSON through
shlex.quote()before writing it t…