Dynamically selecting packages at deployment time

I created a variable at the level of a common variable on the Tenant. The Tenant’s name is set to “QA” for one and “Prod” for another. In the process, I added a step to download and deploy packages (PackageID = EService.#{Tenant.Name}). In the library, I have two packages, EService.QA and EService.Prod. However, when I create a release, I encounter an error.



Hi @yurii.zhuravchak.itis.2019

Thanks for contacting us regarding your issue today.
Looking through you screenshots it looks like the tenant variable #{Tenant.ASPNETCORE_ENV} doesn’t get evaluated on release creation.

This is expected, project variable are only evaluated on release creation.

Kind Regards,
Dom.

How to resolve this? I need to use different packages “id” for deployment.

Hi @yurii.zhuravchak.itis.2019,

The problem is that the tenant variables are not evaluated at this stage in the process, which means that Octopus doesn’t have a valid ID for the package search.

The standard solution would be to set a default value for the package ID variable that Octopus can use when the release is created. Then during the actual deployment, this default value will be overridden with the evaluated variable value.

As you’re using tenants, this complicates it slightly, but it should still be possible by adding a project-level variable of the same name with the default value.

e.g.
Project Variable:

Tenant Variable:

Create Release uses project variable value:

Deployment uses tenant variable value:
image

Regards,
Paul

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