Get Completed Deployments Output Variables via API

Hi;

I was wondering if it was possible to get what the output variables were set to, from a completed deployment, via the REST API?

I haven’t been able to find anything in the doco, swagger output, or just general querying of data.

Thank you!

Hi @smithplatts,

Thanks for reaching out and welcome to the Octopus community!

I’ve ​managed to locate a Steps’ Output Variables by navigating via the API under:
https://<OctopusInstance>/api/Spaces-XXX/variables/variableset-Deployments-XXX

From there the output variable will have a name like:
Octopus.Action[<StepName>].Output.<VariableName>

Deployment Id’s can be found via a Release’s Deployments:
https://<OctopusInstance>/api/Spaces-XXX/releases/Releases-XXX/deployments

I have to admit our documentation could definitely be improved regarding this, thanks for raising it!

Feel free to let me know if you have any issues or questions.

Best Regards

Thanks for the response @finnian.dempsey!

Unfortunately, I have already tried that endpoint, and it does not have any of the variables that have been set during the process, only the ones defined at the initiation of the deployment.

To clarify, I’m wanting to capture, post deployment, any variables that have been set by Set-OctopusVariable, which are supposedly Output Variables?

Sorry of my terminology is wrong, I’m rather new to Octopus Deploy.

Edit: Just in case, we are using version 2019.9.7 LTS, if that could be the reason for absence of data?

Hi @smithplatts,

I am just stepping in for Finnian while he’s offline. Sorry to see that did not work for you.
Unfortunately, you are correct, 2019.9.7 does not show output variables at that endpoint. We do have a few ways you could capture the output variables in your version, though.

One way would be to use the Step Template Save an Octopus Output Variable. A project variable set type might be what you’re after here:


Once the deployment is run you would find the variables under Project > Variables > Project

A second option would be to create an Artifact that you would pass the Output variables into. You could then use API endpoints to view the Artifact. The endpoints are then created, for example:

This endpoint would get the artifact items localhost/api/Spaces-1/artifacts?regarding=Deployments-6

Then you could navigate to “Content” for example localhost/api/Spaces-1/artifacts/Artifacts-5/content to view.

The third option would be to upgrade to our latest version which may be inconvenient but is recommended. Later versions of Octopus Deploy would allow you to see the Output variables on the /variableset-Deployment-XXX endpoint as Finnian suggested.

Please let me know if you have any more questions.

Regards,
Garrett

1 Like

Hi @garrett.dass;

My sincerest apologies for the belated response.

Thank you for the information, and potential solutions! Greatly appreciated.

Unfortunately the upgrade option isn’t something I can influence, but the other two are viable, so I will progress with one of these.

Thank you again!