Can you expand a little more on how you’re trying to use the sensitive variable and the exact issue you’re encountering?
It looks like even when you set the variable to Text it also didn’t work?
If that is the case, then the problem may be that the scoping on the variable is incorrect.
To help troubleshoot that it can be useful to navigate to Project > Variables > Preview and apply the relevant filters to ensure that the variable appears in the list.
Another option would be to add the system variableOctopusPrintEvaluatedVariables with a value of true to your project variables. This will then list all of the variables and values available to each step within the task log.
I have PowerShell script which is responsible to connect with SFTP server via winscp . I am able to connect successfully with the variables values I am passing manually via Windows PowerShell ISE but when I am trying it octopus deploy it is getting failed.
I have enabled the system variable setting as you have suggested. Please have the PowerShell script along with task id. Also, octopus deploy deals differently for Exit Code 0. If you see in release, the step is actually failed but octopus deploy still make is successful.
I’ve looked through the logs, and the variable is being evaluated correctly within the script. So, all I can suggest is to confirm that the passphrase being used is correct. You could try copying it out of Octopus and running the script outside of Octopus so see if the same error occurs.
Regarding the step showing as success when it is encountering an error, Octopus will only show a failed deployment if it receives a non-zero exit code. The error message suggests that it may be sending a zero code despite the issue e.g. Server sent command exit status 0.
You may need to amend your catch block to set the exit code.
Adding $global:LASTEXITCODE might work, otherwise you can set the code directly with exit <nonzero-integer>