Newline / line breaks getting lost on deployment

We have an application.config that for reasons has an xml element who’s value is actually yaml text. The inline editor allows this to be added as a multi line block of text, but by the time it is deployed onto a target the line breaks have been lost, and its a single line, which breaks the yaml.

The issue is very similar to this - Newline characters in variables lost when editing inline · Issue #5687 · OctopusDeploy/Issues · GitHub - which suggests was fixed in 2019.11.2, but its still present in Octopus Cloud which is on 2020.6 (I set up an account to check, on on-prem server is running an older version).

Should I be using special chars / escape chars to manage this or is this the same bug/behaviour as described in the 5687 issue. If so, is there a fix date?

Many thanks

Hi Ross,

Thanks for reaching out - this sounds unfortunate. Are you able to provide a specific example of the variable you’re using, as well as what deployment feature (Structured Configuration Variables, Substitute Variables in templates, .Net XML Transforms etc.) you’re using to replace the values?

I’ll dig into this and get an issue raised for triage by the team!

Look forward to hearing from you soon!

Thanks Justin. I’m using variable replacement via the .NET Configuration Variables feature.

If you create an application.config with the following content, and store as a package:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="ConnectionString" value="" />
    <add key="SecondaryConnectionString" value="" />
    <add key="configCacheTimeout" value="10" />
    <add key="YAML" value="
- !queue
    processName: Process1
    assemblyFile: process1.dll
    startup: true
    degreeOfParallelism:
      maxWorkerThreads: 0
      maxIoThreads: 0
    timings:
      initialTimeout: 00:00:05
      conversationTimeout: 00:00:30
      sleepOnProcessException: 00:01:00
      sleepOnProcessNothing: 00:00:05
      sleepOnProcessSomething: 00:00:01
      sleepOnProcessAbort: 00:01:00
"/>
  </appSettings>
</configuration>

then create a YAML variable in the project using the editor so it definitely saves as multiline, with some similar but modified content to the original:

- !queue
    processName: DifferentProcess1
    assemblyFile: differentprocess1.dll
    startup: true
    degreeOfParallelism:
      maxWorkerThreads: 0
      maxIoThreads: 0
    timings:
      initialTimeout: 00:00:05
      conversationTimeout: 00:00:30
      sleepOnProcessException: 00:01:00
      sleepOnProcessNothing: 00:00:05
      sleepOnProcessSomething: 00:00:01
      sleepOnProcessAbort: 00:01:00

And then deploy, you should see that the resulting deployment contains the modified variable value, but its set as a single line string.

I hope this makes sense. Thanks for your help!

Hi Ross,

Thanks for providing that great extra bit of information. I was able to reproduce this locally using the same information, and wanting to have a bit of a closer look at this one. However a quick test using the Substitute Variables in Templates feature instead of .NET Configuration Variables substituted the multi-line variable value into the config file correctly. This approach requires you to change to the config file to use the substitution syntax (e.g. <add key="YAML" value="#{VariableName}" />) so not sure it’ll help, but thought I’d throw it out there in case it does. :slight_smile:

Best regards,

Kenny

Thanks Kenneth. We might be able to do something in our build pipeline to insert the substitution string before it creates the nuget package that gets uploaded to Octopus, so thats potentially a viable workaround with a little creativity :slight_smile:

Thanks a lot,
Ross

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.