Scheduled deploy using Web Api

Hi,
My customer has a requirement that I do auto-deploy of some software before they come to work in the morning. I though I would do this using a scheduled task that runs a powershell, which calls web api methods in octopus. If you have a better idea, please tell me =)

Problem is; my octopus project has some input params that a user normally supplies before deploy. How on earth can I do this via script instead?

I have tried using Fiddler to test this:
Verb:POST
Header: X-Octopus-ApiKey:xxx
Url: http://octopus-server/api/deployments
Request body: {“ReleaseId”:“Releases-xxx”, “EnvironmentId”:“Environments-xx”, “Comments”:“testing auto deploy”, “FormValues”:{“Some_parameter_name”:“some value”}}

I have also tried posting the parameters in all sorts of ways I can think of (as an array, as values directly in the body, using parameter caption instead of parameter name etc etc), but I only get:
ErrorMessage": “There was a problem with your request.”, “Errors”: [
“Please provide a value for the following variables: Caption for some parameter\r\nOnce you have corrected these problems you can try again.\r\nIf the problem is related to a variable you will need to update the variables for this release or recreate the release for the changes to take effect.\r\nIf the problem is related to the deployment process you will need to create a new release for the changes to take effect.”

Could you please give me a hint on how to do this correctly?

Regards
-Gard Ellefsen
(Using version 3.1.3)

OK. Figured out that I need the variable Id…
So a request body would be {“ReleaseId”:“Releases-xxx”, “EnvironmentId”:“Environments-xx”, “Comments”:“testing auto deploy”, “FormValues”:{“c5e76754-948a-abb9-885b-a8588b53bdfa”:“some value”,“871f9ec3-aef6-9d61-55d0-eaacf58390d9”:“something else”}}

But still, is this the best way to do this? And as a side-note to the shceduled deploy; I am aware of the built-in stuff “deploy later” and autodeploy when packages are uploaded (lifecycle-things). These are not options that I may use.

Hi Gard,

Thanks for reaching out!

I though I would do this using a scheduled task that runs a powershell, which calls web api methods in octopus. If you have a better idea, please tell me =)

This is definitely the way to go, but instead of using the API, I’d recommend you to use Octo.exe. This is a command line tool built on top of the Octopus API, that incapsulates the most basic and necessary features such as Creating and Deploying releases.

What you’ll need to do is use Octo.exe create-release along with the following parameters:

  • deployto to deploy the release to an environment as soon as you create the release

  • variable to pass values to your project’s prompt variables

Octo.exe doc: http://docs.octopusdeploy.com/display/OD/Octo.exe+Command+Line

Octo.exe create-release doc: http://docs.octopusdeploy.com/display/OD/Creating+releases

Hope that helps!

Dalmiro

Great! This seems to be the way to go. Thank you so much!
Regards
-Gard Ellefsen