There are certain special circumstances where we create a release for a project but we don’t want to run a deployment via Octopus for that release (instead needing to deploy it a different way) however we would still like the dashboard to show the correct deployed version for a given project.
Is it possible to update/set the current deployed version of a project in an env using the REST API without causing it to deploy?
e.g. for project x, version 2.0.0 is deployed in environment ‘development’
Thanks for the help!
Thanks for getting in touch!
A deployment does need to exist for Octopus to display that version on the dashboards.
It feels flaky, but the only way I can see to do this is to initiate a deployment, immediately cancel it, and then use the Edit State option to set it to successful.
Thanks for the quick reply!
That makes sense.
So there is now real way we can do this via the REST API?
We would need this to be automated really so doing it manually via the UI may not be possible in this scenario.
After the other process has deployed the release, it would make said REST request back to Octopus to just let it know it has deployed the certain version itself.
Everything that can be done in the UI uses the REST API, so it is definitely possible to script this.
You can use the browser dev tools to catch the API calls being made when performing the deploy, cancel and state change within the UI to see the specific endpoints and payloads being used which should make creating the script easier.
It would be along the lines of:
POST api/<spaceId>/deployments - need project ID and release ID. Capture TaskId from response
POST api/tasks/<taskId>/cancel - cancels the deployment
POST api/tasks/<taskId>/state - change the state to successful
We have some sample scripts for creating and cancelling deployments that may be useful too.
Thanks @paul.calvert! This is very helpful!