Facing an issue where octopus system variables are not resolving

Hi,
We are facing an issue where octopus system variables are not resolving.

We get the error Cannot open database "OSO_NG_#{Octopus.Environment.Name | Replace “-” “_”}"
NotSpecified: Exception calling “Extract” with “4” argument(s): “Could not connect to database server.”

Deployment variable preview:
image

And even in preview its not resolving. We are using the SQL-Deploy DACPAC step template.
I can send on the Task Log if you need it.

Kind Regards,
Micheál Power

Hi @mikepower79

I’ve quickly done some testing and it seems to be working fine for me, with the exact variable you are using in your setup.

My Variables Screenshot:

This means it could be one of the following issues:
1.) depending on the version of Octopus you are running, there may have been a bug which has since been fixed. I’m running 2022.3.349

2.) You’ve targeted the variable incorrectly in DACPAC step under “Target Database”.
The way the variable should be written in your DACPAC step is exactly like this:
#{EF.SQL.DBName}

3.) You’ve put your variables somewhere else, and they don’t evaluate correctly based on the order of the Octopus Deployment Process. I’ve entered the variable into my “Project Variables”.

If you put “OctopusPrintEvaluatedVariables” and “OctopusPrintVariables” in your variables and set their values to “True”, (as per my picture) the evaluated variable should be printed in your logs, so you can check on the result.

Let me know how you go.

Regards,

Hi @dane.falvo,
The Octopus version we are running is 2021.3.12372
We have updated the variable as you said in step 2 but still getting an error.

Kind Regards,
Micheal Power

even we tried step 3 its not resolving into values, we still have the issue

Hi @mikepower79 and @v.ambareesh

Thanks for the update. That’s very odd. I will look through some old issues to see if there is any old issues that were reported around variable substitution.

Would you please send me through the Task Logs with the evaluated variables switched on. Would you also please provide me with the output of the Deployment Process as described here?

You can upload those files to this private link: Support - Octopus Deploy

Please, let me know when those files are uploaded by replying to this message, otherwise I will not be alerted to the upload.

Regards,

Hi @dane.falvo,
Just uploaded the log file.
From different project but the same issue.

Kind Regards,
Micheál Power

Hi Mike,

I installed 2021.3.12371 and everything worked fine for me as well.
Then I took a good look at your logs and worked out the issue.

You’ve got two spaces in between the word ‘Name’ and the ‘|’ character.
OSO_NG_#{Octopus.Environment.Name | Replace “-” “_”}

Sure enough, when testing with the two spaces in that spot - my substitution didn’t work as well.

I’ll be raising this as a bug but please, fix up that variable and let me know if it works for you.

Regards,

Dane

Hi @dane.falvo,
Yes that fixed the issue.
Thanks for your help,

Kind Regards,
Micheál Power

1 Like

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