Running custom script from package

Hi,

I have a step to run a custom script that removes the server from the loadbalancer. This script is uploaded to octopus as a nugetpackage. The problem is as follows:

MyScript.20180607.1.nupkg is uploaded (yesterdat as you can infer from the number)
Deploy of SomeLoadBalancedProject is run with number “20180608.1” (today as you can infer from the number)
I get then the following error when trying to deploy:
The package MyScript 20180608.1 could not be downloaded to the package cache from Octopus Server

As you can see, the script package version to be downloaded matches the version of my deploy instead of matching the latest version of the script itself

I don’t know if this is an issue or by design. Are there any alternatives?

thanks in advance

Hi,

Thank you for getting in touch. I think the problem is that when you created the release, you specified 20180608.1 for the MyScript package version (as well as the release’s version). You should specify 20180607.1 or just accept the largest version number instead.

Most likely you will find that when you go to view the Octopus Release details, it will show “Package not found” in the packages list.

If you are still having trouble, could you please expand on how you are creating the release, including commandline calls and screenshots. Also a raw task log and screenshot of the release details would be helpful.

Rob W

Oh I get the cause, the thing is I create a release using the api and the package version I specify is with the parameter --packageversion. I should use --package=“My script step”:desiredVersion to override the packageversion parameter.

Is there a way I can specify the desiredVersion for a step to be the latest version available of the package?

Thanks for your answer!

Hi,

I don’t think there is a way to do that using Octo.exe. This is the source code for that command.

An alternative is to use the Octopus.Client .NET package or PowerShell and retrieve the latest version from the API. Here is an example in C# and one in PowerShell. Also see OctoPosh.

Rob W

Hi Robert,

That is just what I figured out in the meantime, I use a powershell script to retrieve the latest version and use that version for the package parameter

Thanks for your help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.