Came across this post https://github.com/OctopusDeploy/Issues/issues/683, which suggests this has been implemented. How can I instruct Octopus Deploy to leave deploy.ps1 etc. (i.e. not deleting the file) after a successful release?
Thanks
Came across this post https://github.com/OctopusDeploy/Issues/issues/683, which suggests this has been implemented. How can I instruct Octopus Deploy to leave deploy.ps1 etc. (i.e. not deleting the file) after a successful release?
Thanks
Hi Richard,
Thanks for reaching out. You’re gonna need to add a variable called OctopusDeleteScriptsOnCleanup
and set its value to false
(see attached screenshot). After doing so, create a new release and you’ll notice that deploy.ps1 won’t be deleted.
Thanks!
Dalmiro.
Thanks that works, but the PowerShell variables aren’t been replaced with those specified in Octopus. Ideally I’d like to have:
(deploy.ps1)
$svc = ‘$ServiceName’
(In Octopus)
Variable ServiceName set with a value of “Test Service”
The deploy.ps1 file left on disk after deployment replacing $svc = $ServiceName with $svc = ‘Test Service’
Is this possible?
Thanks,
Richard
Update: I was able to achieve my goal using the following Powershell in the PostDeploy.ps1:
$preDeploypath = "PreDeploy.ps1"
$deploypath = "Deploy.ps1"
$preDeploytext = get-content $preDeploypath
$deploytext = get-content $deploypath
foreach ($key in $OctopusParameters.Keys)
{
$paramName = ("{0}{1}" -f '\$',$key)
$preDeploytext = $preDeploytext -replace $paramName,$OctopusParameters[$key]
$deploytext = $deploytext -replace $paramName,$OctopusParameters[$key]
}
$preDeploytext > $preDeploypath
$deploytext > $deploypath
Hi Richard,
Glad to hear you sorted it out. Cheers!
Dalmiro