This is Part II in our series “Continuous Integration with Visual Studio Online, Octopus and Team City”. This material was created and presented by Dante Papada at Philly .NET Code Camp on March 21, 2015.
To view Part I click here: http://anexinetappdev.blogspot.com/2015/03/continuous-integration-with-visual.html
Step 1 – Prior to creating the release in Octopus we need to get some information from the Octopus REST API. Perform an HTTP GET on the following URLs:
http://octoweb01/api/projects/all - Identify the Project Id of the desired project to create a release.
http://octoweb01/api/environments/all - Identify the Environment Id of the desired environment to deploy the release.
Step 2 – To create the release in Octopus perform an HTTP POST on the following URL. In the payload you must include the Project Id and the version number:
http://octoweb01/api/releases
Payload Example:
{"ProjectId":"projects-4",
"Version": "0.0.42"}
The response after this successful POST, will yield the “Release Id”. An example would be the following:
{
Id: "releases-141"
Assembled: "2015-03-19T03:06:33.006+00:00"
ReleaseNotes: null
ProjectId: "projects-4"
ProjectVariableSetSnapshotId: "variableset-projects-4-snapshot-1"
LibraryVariableSetSnapshotIds:
[
1]
0: "variableset-LibraryVariableSets-1-snapshot-17"
-
ProjectDeploymentProcessSnapshotId: "deploymentprocess-projects-4-snapshot-17"
SelectedPackages:
[
0]
Version: "0.0.42"
…}
Step 3 – Perform an HTTP POST on the following URL, with a payload that contains the Release Id (obtained from the response from creating release) and the desired Environment ID (obtained from the response from getting the Environment data):
http://octoweb01/api/deployments
Payload Example:
{"ReleaseId": "releases-141",
"EnvironmentId": "Environments-1"}
The response after this successful POST, will execute the deployment defined by the identified release:
{
Id: "deployments-174"
ReleaseId: "releases-141"
EnvironmentId: "Environments-1"
… }
Now you will see the following result in the Octopus Deploy dashboard:
For additional information:
https://github.com/OctopusDeploy/OctopusDeploy-Api/wiki
http://docs.octopusdeploy.com/display/OD/API+and+Integration