Inconsistent json snippet variable output Powershell and Bash

oskar.bos's Avatar

oskar.bos

12 Aug, 2017 10:08 AM

Hi everyone,

I am evaluating Octopus deploy for improving our DevOps and continuous delivery practices. We have.Net framework applications that run on Windows hosts, and .Net core applications that run on Linux.

I have created a single project to tinker with, with a Windows tentacle (Windows 10) and an SSH tentacle to Ubuntu desktop. The SSH tentacle uses the option "Mono not installed".

Now I created a simple JSON snippet variable (called "Configuration.Json") and attempted to use that snippet in both Powershell and Bash scripts. In Bash, I tried to reference the variable from a script defined in Octopus, and from an external Bash script in the package. All three should, in theory, have the same output, but it's all different.

Step 3 in the screenshot: The Powershell output is correct, the entire string as defined in the variable is printed. The script is simply:

Write-Host $OctopusParameters['Configuration.Json']

Step 4 in the screenshot: The Bash script from source has the entire string, but the quotes are gone making the JSON invalid. The script looks like:

echo "#{Configuration.Json}"

Step 5 in the screenshot: The external Bash script has both the quotes and part of the string missing. The script looks like this:

echo "$1"
The following argument is passed to the script: "#{Configuration.Json}"

Can someone help me achieve more consistent behavior? Thanks in advance for the help!

Kind regards,
Oskar uit de Bos

  1. Support Staff 1 Posted by Shane Gill on 15 Aug, 2017 05:33 AM

    Shane Gill's Avatar

    Hi Oskar,

    Thank you for getting in touch. Apologies for the delay getting back to you.

    In bash, when you echo "#{Configuration.Json}" you are essentially doing: echo "{ "name": "John", "age": 31, "city": "New York" }". Try the latter and you will see that it returns the same result that you are seeing because the inner quotes are being interpreted. You need to use strong quoting (single quotes) so the contents of the string are not interpreted: echo '#{Configuration.Json}'.

    I hope this helps.

    Cheers,
    Shane

  2. 2 Posted by oskar.bos on 15 Aug, 2017 07:50 PM

    oskar.bos's Avatar

    Hi Shane,

    No need to apologize, it was the weekend after all! Your suggestion solved my problem right away. Feel a bit silly that I didn't figure that out by myself after some trial&error. Let's chalk it up to the weekend :)

    Thanks for the help!

    Regards,
    Oskar uit de Bos

  3. oskar.bos closed this discussion on 15 Aug, 2017 07:50 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac