Multiple variables on one line?

Hi,
Hope you may be able to advise…

Is it possible to have multiple variables on one line?

I have a PowerShell script that creates either windows or SQL logins and expects the format to be “username”|“password”

If i have #{username}|#{password} within my multi line variable it will return the correct username but fails to retrieve the correct password and simply returns the text “#{password}” and so my step fails.

The step runs fine if the password is hard-coded.

Just wanted to check there was a way around this before altering the PowerShell scripts expected format.

Cheers!

Hi Nick,

Thanks for getting in touch!

I’ve run a quick test on this using the below script and it is returning both values.

$multiLine = "#{username}|#{password}"
Write-Host $multiLine

It may be that I’ve oversimplified the test though.
If you can confirm which version of Octopus Server you’re running and share the relevant lines of your script we can re-test.

Regards,
Paul

Morning Paul,

We are using v2019.12.3 LTS

If I enter the variable as per below:

It seemingly fails to retrieve the password:
image

Hope this makes it a little clearer!
Cheers
Nick

Tested this again using a multi-line variable and the same version and it does seem to be working.


How are you using this multi-line variable? Is it part of a variable substitution or something else?
Also, are you sure that #{uk.db.developers.password} is scoped correctly for this deployment?

Well… This is embarrassing :blush:

No, it was not scoped correctly… As the user was not scoped at all yet the PW was (now apparent) I didn’t even think to check.

Thanks for your time!

Promise to try harder in future :wink:

No worries, glad it is working now :slight_smile:

1 Like

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