Can I pass variables from one task to another?

I need the ability to check something in one task and pass that information along so the rest can react to it. Here is my scenario.

Step 1: Check to see if Database requires upgrade

Execute if database requires upgrade

  • Disable Sites
  • Disable Tasks
  • Upgrade Database

Execute always

  • Upgrade Sites

Execute if database requires upgrade

  • Enable Tasks
  • Enable sites

Having the ability for the subsequent tasks to check and skip their task would be the easiest way for this to occur and would cut quite a lot of time off of a full deployment. As it stands right now I have 4 different deployment tasks each performing a part of the deployment so I can manually kick of certain pieces. But I’d like to just have 1.

Even a way to add variables to the $OctopusParameters and have them persist between tasks should work just fine. Let me know what you thin.

Hi Nathan,

I like this suggestion, and it could certainly be done. I’m not quite sure what the scoping for this would be (would variables returned by machine A be passed to machine B?), but I’m sure if we think about it there are logical answers. I’ve added it to Trello for others to vote on:

(It’s on the v2 suggestions list as “pass variables from one step to another”)


Just a thought - if you needed to get around this right now, one way would be to have your PowerShell script write to a file (in a parent folder) and have the next script read that file. PowerShell’s XML support would make that pretty nice.