Optional variables in project variable templates?

I’m in the middle of moving a project to the new multi-tenant configuration. I have several variables for which the value is not set for a particular tenant. It does not appear there is a way to include those variables into the project variable template without requiring a value to be provided for each tenant. I get a “Some of the required variable values have not been set.” warning.

Is there a way around this? Can I just ignore the warning? It would be great to be able to mark a template as having an optional value, so as to avoid the warnings all over the place.

Hi Pete,

Thanks for getting in touch! It sounds like you’re getting going with Octopus 3.4 straight away - I’m really glad to hear it!

At this point we consider variable templates as “required” from a tenant before you can deploy to them. We considered making variable templates have an “optional/required” setting, but didn’t want to complicate things without good reason.

You can safely ignore the warning until you want to deploy your project to a specific tenant or group of tenants. A missing variable on a specific tenant will only prevent deployments to that tenant - you can continue to deploy to all of your other “correctly configured” tenants.

The intention behind this choice is that variable templates can provide a measure of safety that wasn’t easy before 3.4 - you could accidentally deploy your project to a “misconfigured tenant” without realising some variables were missing, most likely ending with a failure.

The way we saw it working is that when your project deployments require a new variable value, you would:

  1. Add the variable template because your project requires it to successfully deploy
  2. Easily see which tenants were missing values
  3. Set the values on tenants one-at-a-time, in batches, or all at once, deploying to those tenants at your discretion after setting the new value

Right now you could set a default value for the variable templates, which would make all of the warnings go away, knowing that the default value would be used for all tenants that don’t override the default value.

I’d be really interested to understand more about your situation and your experience migrating your existing project to a tenanted project. :slight_smile:

Hope that helps!
Mike

Pete,

We also ran into this problem setting up our tenants. In our case, majority of the values defined by the project are used in a web.config replacement. Some of these values are required to be an empty string for most deployments, but occasionally the value needs to be populated, so needs to be included in the project variable template.

Our solution was to create a variable set that is shared between all tenant-enabled projects (which I believe is a suggested practice). This variable set contains a variable ‘Empty’, which has no value and no scope. For the project variables that need the empty string value, we set the default value to #{Empty}, which can then be overridden on a tenant-by-tenant basis, and doesn’t trigger a warning if not addressed.

We would also like to see variables be marked as optional, or at least be able to specify that a blank value is valid, but for the time being this seems to work well.

James and Mike,

I’m using the variables to substitute into web.config appSettings.

I’ll try James’s idea of using an Empty variable as a default. I agree that allowing templates to be marked as optional may introduce too much complexity.

Thanks!

Hi Pete,

I’ve created a GitHub Issue after discussing it further with the development team: https://github.com/OctopusDeploy/Issues/issues/2709

You can close this ticket and watch the issue if that suits you.

Hope that helps!
Mike