How to dynamcally select package version when creating a release

Hello,

We have a deployment that uses one image for the Staging environment and another image for the Production environment. Both come from the same External Feed but from different Packages Id:

website-frontend/blog/staging
website-frontend/blog/production

We created two channels, one per environment so that we can deploy each image in the appropriate environment. As mentioned in the documentation, we can dynamically select the package id using a variable and scope it by environment:

The issue is that when creating a release, since the package ID is a variable, it doesn’t allow us to select a version, as apparently values from variables are populated at deployment time and not at this stage:

How can we dynamically select packages and their versions?

Thanks!
Kind Regards,
Nicolás Spencer

Hi Nicolás,

Thanks for getting in touch!

You’re correct that the issue is that the variable isn’t evaluated until the deployment starts.

The way to work around this is to add a value that is unscoped. That way, the release can use the unscoped value to populate the package field; you can then select the desired version. When the deployment runs, it will override the package ID with the relevant value for each environment.

Regards,
Paul

Hi Paul, thank you for your quick answer. We’ll go for that workaround.

Thanks!

Regards,
Nicolás

1 Like