I’m having some issues working with the REST API to complete two actions:
First, I need to query the REST API to return the current deployed release for a specific project for a specific tenant.
Secondly, once I have that information, I need to initiate a reinstall of specific steps of that release/project for that specific tenant.
I’m supporting an application that for some reason is hard coding ADFS signing certificates into the web.config file. Thus far I’ve been able to build automation that takes a new certificate from ADFS, imports it into Octopus Deploy and replaces it, and then executes a specific runbook to push the certificate out onto the requested servers based off of the tags. However to update the hard coded value in the configuration, I want to reinstall a component of the release, however I need to know the current installed version so I can call the correct version to reinstall. The bonus would be if I could schedule the release deployment to run in the future, but at this point I am hitting a hard wall on numbers 1 and 2 from above.
Any thoughts or advice would be greatly appreciated.
I found the best endpoint to hit is the tasks endpoint. As you can see by the task UI, you can filter results based on Project/Environment/Tenant.
The API URL matching that screenshot is: https://samples.octopus.app/api/tasks?skip=0&environment=Environments-784&tenant=Tenants-241&project=Projects-1302&name=Deploy&spaces=Spaces-682&includeSystem=false
That URL returns a list of tasks. Within those tasks is a deployment id.
You can then use that deployment id to find the release id in question (https://samples.octopus.app/api/Spaces-682/Deployments/Deployments-73210)
I hope that helps!
That does help. I was also able to pull the info with call to deployments api endpoint and then returning 999 results, then doing additional filtering to find the project and tenant I’m looking for.
For both of these ways (deployment or tasks), the results are being returned in most recent to oldest order, correct?
The one final question I would have is – can you schedule a deployment to happen at a specific time through the API? I’ve been looking through the examples and it doesn’t seem like it. Ideally when this triggers, I’d like to get the redeployment to happen after hours automatically. The other option I have is to simply change the time when all of this executes, if there’s no possibility of scheduling a deployment via API call.
Q: For both of these ways (deployment or tasks), the results are being returned in most recent to oldest order, correct?
A: Yes. If all I am interested in is the most recent deployment, I’ll add &skip=0&take=1 to the URL to pull back a single record.
Q: Can you schedule a deployment to happen at a specific time through the API?
A: What I’d suggest is to leverage the Octopus Runbook feature to trigger a runbook that will run a PowerShell script. That PowerShell script will trigger the deployment. The easiest way to trigger a deployment is to use the Octopus CLI deploy-release command. Deploy release - Octopus Deploy
I hope that helps!
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.