Updating variables in file using the run powershell script step

martenolofsson's Avatar

martenolofsson

04 Feb, 2018 04:40 PM

Hi,

I have an application which is deployed to azure through octopus deploy. It contains two steps, the first is to run a console application, IE trigger an EXE file through powershell. In the package where the exe exists there is also a config file which is used by the application. Is there a way to replace variables in this file before the exe is executed in the same way I can replace variables in file while using the deploy a nuget package step?

Best,
Mårten Olofsson

  1. Support Staff 1 Posted by Reece Walsh on 05 Feb, 2018 05:29 AM

    Reece Walsh's Avatar

    Hi Mårten,

    Thanks for getting back to me regarding this,

    It's definitely possible to replace the variables in this config file using the Configuration Variables feature.

    Using this feature, it's also possible to replace settings that exist outside of appSettings, applicationSettings and connectionStrings.

    This method will work provided the EXE file you specified, is also contained within the package being deployed.

    I hope this helps!

    If you require further information or clarification please let me know :)

    Kind Regards,

    Reece

  2. 2 Posted by martenolofsson on 05 Feb, 2018 09:00 AM

    martenolofsson's Avatar

    Hi Reece,

    I know that this feature is available when for example deploying a webapp, but I want to do this using the "run a script" template. As far as I can see the "features" section is not available then.

    Best,
    Mårten

  3. Support Staff 3 Posted by Reece Walsh on 06 Feb, 2018 03:39 AM

    Reece Walsh's Avatar

    Hi Mårten,

    Thanks for getting back to me regarding this,

    It sounds like you are wanting to substitute a variable in a file that's not in a package being deployed.

    In that scenario, you could try specifying an absolute path in the substitute variables in files feature (i.e. C:\Octopus\text.txt), since this is only a feature of package steps, not script steps. You could potentially deploy an empty dummy package to utilize this feature.

    All of the supported scenarios can be found within the Advanced Configuration Transforms Examples area of our documentation.

    If I've misunderstood in any way or you require further assistance please let me know :)

    Kind Regards,

    Reece

  4. 4 Posted by martenolofsson on 15 Feb, 2018 03:03 PM

    martenolofsson's Avatar

    Hi Reece,

    Actually, what my scenario looks this :I have a package that I'm deploying but as one step of the process I want to run a script which invokes a console application (exe) (which is located in another package with the same id - not really my prefered approach but....) and that application has a config file in which I want to update some variables before executing the script.

    What exactly do you mean when you say "deploy and empty dummy package"? Using a "deploy a package" to get hold of the configuration variables feature but not actually deploy a package?

    Kind Regards,

    Mårten

  5. Support Staff 5 Posted by Reece Walsh on 16 Feb, 2018 05:57 AM

    Reece Walsh's Avatar

    Hi Mårten

    Thanks for getting back to me,

    I appreciate the breakdown you have provided in your most recent comment, it really helps out!

    I originally mistakenly believed that there was no package being deployed at all, which is what led me to mention that you would need to deploy a blank package in order to access the necessary features you required.

    However, since you are already deploying a package, you can enable the Config Transformation feature as previously mentioned within the package step, in addition to enabling the Custom installation directory feature to specify the location of the config file that is not contained within the package currently being deployed.

    I hope this helps!

    Please let me know if you require any further assistance, I'd be more than willing to help :)

    Kind Regards,

    Reece

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac