How to Pass Octopus Variable to SQLCMD Dacpac variable?

I need to deploy sql dacpac via octopus deploy.

  1. I am using SQL - Deploy DACPAC step to deploy.
    2.I have a variable in DACPAC which i have in SQLCMD variable. I need to pass the value to this variable from octopus deploy.
    3.So i added the variable in octopus deploy also. as well as i added the variable in SQL - Deploy DACPAC.
    4.But it is throwing error. So i googled it. I got the below line.
    $options.SqlCommandVariableValues.Add(“ImportantVariable”, $ImportantVariable)
    5.But i dont where i need to add this ?? Anyone help on this?

Hi @sha1,

Thanks for getting in touch! I may need to get some more information from you here but I think I may have something which will help you.

If you are trying to create a variable during your deployment, we have a feature called Output Variables. The documentation has some good details about how this feature works. Essentially, you can use the following syntax in one of your scripts in Octopus to create a variable which can be used in any subsequent steps during the deployment.

Setting variable in script:
Set-OctopusVariable -name "TestResult" -value "Passed"

Calling variable in later step:
or in other scripts:
$TestResult = $OctopusParameters["Octopus.Action[StepA].Output.TestResult"]

When calling this variable, you need to make sure the name of the step you created the variable in is referenced in the square brackets.

Does this let you achieve what you are after here?

If this is not what you need, you will need to provide some more details about where you are trying to set this variable, and how you need to reference it.

Looking forward to hearing from you. :slight_smile:

Best regards,

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