Substitute Tenant/Project Variables In config Files

Hi Team,
I am trying to create an project which can take the variable values from Octopus[from a different Project] and substitute in the Config File. I was able to do this for the Library VariableSets values but this did not replace the Tenant Level or project level Values, Is there a way to do it in Octopus Deploy where one project can run and take the values from Variables and update in the Config for multiple projects ?

Thanks,
Sujesh Sasidharan

Hi Sujesh,

Thanks for reaching out!

Sadly, the short answer here would be: Its not possible. The whole idea behind Library Variable Sets is that they can be shared across projects (just like you are using them :+1:) in opposition to regular project level variables which only exist within the context of that project .

The only workaround I can think of is to write Project1 's variables somewhere in disk/database during a deployment of that project, and then grab those values when deploying Project2 .

I know its not the answer you were looking for, but I hope it helps in some way :).

Regards,
Dalmiro

Hi Dalmiro,
Thanks for the reply. I have 2 more questions from my end.

  1. I was able to retrieve the Project Level Variables using Octoposh but was not able to retrieve the Scope details. Is it possible to get the scope details using Octoposh or any other method.
  2. I am also not able to retrieve any tenant level variables , Could you please let me know if we can retrieve it and yes please let me know the steps ?

Thanks,
Sujesh Sasidharan

Hi Sujesh,

I’m afraid Octoposh won’t be able to help you in thise case :/. That open source project hasn’t been maintained since 2017, and the version of Octopus.Client it is using its highly outdated (reason why you are not getting the scope details for example). I can 100% confirm this because I was the creator and (pretty much) only maintainer of that project.

All Octoposh does is translate some functionalities of the .NET library Octopus.Client into Powershell cmdlets. And all Octopus.Client does is put a layer of abstraction on top of our REST API.

With that I’m saying that anything you can do with Octoposh/Octopus.Client can also be done with raw API Calls. Granted, using the API is going to require a bit more effort on your side :slight_smile:

  1. I was able to retrieve the Project Level Variables using Octoposh but was not able to retrieve the Scope details. Is it possible to get the scope details using Octoposh or any other method.
  1. First you’re gonna have to GET the /api/projects/all endpoint to get the list of all the projects and filter the one you want to use.

  2. That project is gonna have an array property called Links which will have a property called Variables. Do a GET on the URL from that variables property and you’ll get your project’s full variable set.

  3. Once you have the variable set, you can dig your way into all the variables and their scopes. Be aware that the variables might be scoped to resources like Environments which will only be referenced by ID (e.g Environments-10). This means that you’ll have to GET several other endpoints(e.g /api/environments/{environmentId}) to get the real names of each of those scoped resources.

  1. I am also not able to retrieve any tenant level variables , Could you please let me know if we can retrieve it and yes please let me know the steps ?

This is a similar story as with projects.

  1. GET /api/tenants/all and get the tenant you are looking for.

  2. That tenant is going to have a LinksVariables property. Use that URL to get the variable set.

I know this is going to require a lot more work from your side than you expected when using Octoposh, but hopefully this info will help you get there in the end :).

Best regards,
Dalmiro

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