Run a deployment step only on untenanted deployment

I have a project that can be deployed tenanted or untenanted… basically the normal CI > QA > PRD is untenanted while there are also tenanted QA environments for developers to do long term work.

I have a step that I would like to run during an untenanted deploy, but skipped if it is deploying to a tenanted (developer) environment. Is this possible?

The step is a PoSh script, so if there is a simple Octopus tenant var I could do something like
if ($Tenanted -ne $True) {Run script}

I did try:
$Tenant = "#{Octopus.Deployment.Tenant.Name}"
if ($Tenant -eq $Null){Run Script}

Apparently in an untenanted environment $Tenant = “#{Octopus.Deployment.Tenant.Name}” sets $tenant to the actual text “#{Octopus.Deployment.Tenant.Name}” instead of leaving it null

Incase anyone finds this… this solution seems to work, not sure if there is a better way.

$OctoAPIKey = "#{OctopusAPIKey}"
$OctoURL = "#{OctopusURL}"
$Header = @{ "X-Octopus-ApiKey" = $OctoAPIKey }
$DeploymentID = $OctopusParameters["Octopus.Deployment.Id"]
$TenantID = (Invoke-RestMethod "$OctoURL/api/deployments/$DeploymentID" -Method get -Headers $Header).tenantID

if ($TenantID -eq $Null){ 
#Do something

Hi Chris,

Sorry for the delay in getting back to you. Yes, that would probably work, however I think we have a better solution for you.

We have a concept called “Run Conditions”. The best place to get all the info regarding run conditions is from here:

Now, because the Tenant.Name variable will be empty until something gets assigned to it, you should be able to use a Variable Expression for your run condition. This should work:

#{unless Octopus.Deployment.Tenant.Name}True#{/unless}

This means that unless the Tenant Name is populated, then Run the step!

Please give that a shot and let me know how it goes.