Hi everyone,
I have a project that includes a step to deploy another project. Using the CLI, is it possible to specify that the latest version of that other project should be used?
For example, if I were to create the project using the CLI like this, every package in every step of the process would be a version 1.2.3 -
dotnet-octo create-release --space Spaces-1 --project Projects-123 --version 1.2.3 --defaultPackageVersion 1.2.3 --ignoreExisting
To specify a particular version for the step that deploys the other project, I can use this -
dotnet-octo create-release --space Spaces-1 --project Projects-123 --version 1.2.3 --defaultPackageVersion 1.2.3 --package DeployOtherProject:4.1.7 --ignoreExisting
However, if I release a new version of the other project, I have to update the buildspec
that I use to create a release of my project. Instead, I would like to do something like this -
--package DeployOtherProject:latest
The only mention latest packages in the documentation is around not using --defaultPackageVersion
and omitting --package
for one or more steps so that packages for the omitted steps use the latest version available at that moment. However, this is not practicle when there are many (around 30) steps in the project that would use the default version.
Perhaps I’m mis-interpreting the docs, but any advice on how to achieve my goal without having to list every individual package would be appreciated.
Thanks,
David
Hi David,
Thanks for getting in touch, and great question! Unfortunately for this situation, you are correct in your interpretation, in that you do have to override any versions that don’t apply to the default version passed in with this command, and there’s no option to pass in anything like latest
to override it per-step. I can certainly see the inconvenience in having to manually update the version on each new release created.
One option to approach this (though definitely not ideal as you would need to make an API call to Octopus), would be to query the latest version of the project in question using a step in your CI server prior to creating the release of this “parent” project. To do this, you’d need to call the API on this URL (replacing in your URL, Space Id, and Project Id):
https://yourURL/api/Space-ID/projects/Project-Id/releases?take=1
.
Using PowerShell, it would look something like this:
$octopusAPIKey = "API-YOURKEY"
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }
$releaseVersionList = Invoke-RestMethod -Method Get -Uri "https://OctoURL/api/Spaces-ID/projects/Projects-ID/releases" -Headers $header
$releaseVersion = $releaseVersionList.Items | Select-Object -First 1
$version=$releaseVersion.Version
Sorry I couldn’t give you the news you were after, but I’m hoping that helps! Let me know what you think, or if you have any other questions or concerns going forward.
Best regards,
Kenny
Hi Kenny,
Thanks for getting back to me. That is a pity, hopefully something that can be addressed in the future.
Thanks,
David
Hi David,
Anytime at all. I’ve raised this question internally to see if there are any plans to support this, or if it could be considered.
I appreciate your question and suggestion. I think this is potentially a fantastic idea, but I’m not sure if there’s a specific reason why it can’t/shouldn’t be supported, so I’m keen to see the thoughts from the appropriate team. I’ll let you know.
Best regards,
Kenny