Tenant Tags

(James) #1

We have over 160 tenants and I need to exclude 8 tenants from a process step and then have a process step for those 8 tenants.

The only way I think I can do it is to use tenant tags, and as I can’t find a way to have a step that Excludes specific tenants, I’ll have to add tags to all tenants and run the process based on the tag.

But this means I need to manually add tags to all 160 tenants - which is very labour intensive.

Is there a way to edit a tag and Add the Tenants it applies to ?

Regards

James.

(Daniel Fischer) #3

Hi James,

Thanks for getting in touch! I have just written a small API script which will let you define a TagSet/TagName, get all Tenants, then add the defined tag to each of them.

This would let you add your tag to all 160 tenants, you can then go through and manually remove the tag from the 9 Tenants which you would like to exclude. Alternatively, you could edit the below script to exclude them.

cd C:\MyScripts\Octopus.Client
Add-Type -Path 'Octopus.Client.dll' 

$apikey = 'API-KEY' # Get this from your profile
$octopusURI = 'http://OctopusServer/' # Your server address

$tagToAdd = "Test2/Tag-A" #tagset/tagname

$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusURI,$apikey 
$repository = New-Object Octopus.Client.OctopusRepository $endpoint

$allTenants = $repository.Tenants.GetAll()

#add the $tagToAdd to all Tenants in Octopus if it does not already contain it.
foreach ($tenant in $allTenants){
    if ($tenant.TenantTags -notcontains "$tagToAdd"){
    $tenant.TenantTags.Add($tagToAdd)
    }
    $repository.Tenants.Modify($tenant)
}

Let me know if this helps you out, or if you have any further thoughts or questions here.

Best regards,
Daniel

(system) closed #4

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