Problem setting OctopusTreatWarningsAsErrors in a script template

Hi

I’ve made a small script template as a wrapper around Web Deploy. Since Web Deploy doesn’t return a proper error code, I have to set OctopusTreatWarningsAsErrors to True. I found this post describing how to set this in PowerShell: http://help.octopusdeploy.com/discussions/problems/11844-setting-octopustreatwarningsaserrors-in-powershell

So I added the following in my script template:

Set-OctopusVariable -Name "OctopusTreatWarningsAsErrors" -Value "True"

But this had no effect: the release succeeded with a warning. If I instead add a variable ‘OctopusTreatWarningsAsErrors’ to the project with the value ‘True’, the release fails as expected.

But this is not desirable, since I’ll have to add this variable to every project using my Web Deploy script template. Am I setting this the wrong way?

One alternative could be to set OctopusTreatWarningsAsErrors globally to true (if so, how can I do this?), but this isn’t an optimal solution either, as there might be cases where I would not like to treat warnings as errors.

Hi Julian,

Thanks for getting in touch!

The Set-OctopusVariable functionality is to return named variables back from a step. You’d need to set OctopusTreatWarningsAsErrors as a variable within your project (which can be scoped to an environment / role etc)

Hope that helps!

Damian

Thank you for the prompt response, Damian.

So if I’m understanding you correctly, there is no way to make a given script template always treat warnings as errors? The template in question will be used across both several domains and roles in many projects, so I really don’t want to have to configure OctopusTreatWarningsAsErrors everywhere.

My preferred solution would then be to set OctopusTreatWarningsAsErrors globally (once for the whole server). And from this post this should be possible since Octopus 2.0 (we’re on 2.6). But I haven’t figured out how… Could you help me here?

Hi Julian,

We have variable sets which allow you to have settings like this and add them to all projects, but manage it from one place.
This would be the only solution.

Vanessa

Thank you Vanessa. I had already figured out the way with variable sets, even though it’s not an optimal solution.

I have to open this issue up again. We just ran into a case where it’s problematic to set OctopusTreatWarningsAsErrors using a variable set. The reason for this is that one step in our release process requires to fail on error, whilst another should only yield a warning.

What do you suggest as a workaround here? It would be really frustrating to have to configure a OctopusTreatWarningsAsErrors variable scoped to that particular step in every project where it is needed (if that is even possible)… And if this isn’t possible with the current version, is there anything in the pipeline that might help on the issue in future versions?

Hi Julian,

Sorry for the delay in getting back to you. It is just not possible for this variable to be set independently for individual steps.
I would suggest putting a suggestion into UserVoice. https://octopusdeploy.uservoice.com/
This will be the best way to get it on our radar.

Vanessa