Closed stuz32 closed 9 months ago
Hey there @stuz32! Is this issue for a specific template or the variable replacement feature overall?
Hello Shawn,
The issue I think stems mainly from the PowerShell example shown on this page: https://library.octopus.com/step-template/actiontemplate-variables-substitute-in-files
I don't think the Octopus library itself is responsible for the issue, it's more related to the documentation presented on this page which makes use of the 'Out-File' method. It seems the PowerShell 'Out-File' method is responsible for this trailing new line character.
So the solution may simply be to verify the following script snippet I provided passes the mustard for the team at Octopus and updating the PowerShell example listed on the page for future users :-)
$EvaluatedTemplate -join "rn" | Set-Content $TemplateFile -NoNewLine
Regards, Sean
Ah! Okay, thank you for clarifying :)
Step template
Variables - Substitute in Files
Step version
N/A
Octopus version
Octostash 2.7.0
Step template parameter inputs
N/A
What happened
Hey team,
Love your product and just wanted to help give back a little bit.
We have been transforming files for quite some time using Octostash in a similar manner shown in the example source code on this page: Click here
We recently had an issue however whereby transforming a json file resulted in a Java application (SOLR) crashing due to the insertion of a new line character at the bottom of the JSON file post replacing Octopus variables with the actual secret values.
I've made a quick post to Stack Overflow so that this might be useful for people specifically looking for this SOLR error, but I thought it worth passing this information along to you for maybe updating the aforementioned Octopus Powershell page to include this method rather than the 'Out-File' Powershell Utility - Stack overflow
Regards, Sean
Reproduction steps
PowerShell ISE
`# Before $EvaluatedTemplate | Out-File $TemplateFile -Force -Encoding UTF8
After
$EvaluatedTemplate -join "
r
n" | Set-Content $TemplateFile -NoNewLine`This results in no new line character being added to the output, and appears to be working with our other file types (Web.Config etc)
More Information
No response