Additional package reference and create Octopus release with Cake

usability
(Emil) #1

Hi Guys,

I am using Octopus Tools of Cake Build script to push the package after a build to the Octopus internal repo and to create a release at the end of the build.

It is the first time I am using the Azure PowerShell Script template to run my own script that is inside a package with an additional package. I was using work arounds to deploy dependency packages in the past.
The additional package has it’s name (referenceid) set as AppPkg as per the blog post example here.

All is good and my script works until at the next build around when Create Release failed with the following error:

There was a problem with your request.

 - More than one package version was specified for the step 'Deploy App'
 - No package version was specified for Deploy App:AppPkg

Error from Octopus server (HTTP 400 BadRequest)
Exit code: -7
An error occurred when executing task 'OctoRelease'.

I guess the Release plan prior the error might be helpful:

Release plan for App 0.1.0
Channel: 'Default' (this is the default channel)
  #   Name                     Version           Source             Version rules      
  --- ------------------------ ----------------- ------------------ -------------------
  1   Deploy App               2019.904.2        User specified     Allow any version  
  1   Deploy App               0.1.0             User specified     Allow any version  

Creating release...

As you can see the two packages are listed and I can’t figure what is wrong…

Below is the configuration of the Cake CreateReleaseSettings object:

                new CreateReleaseSettings
                {
                    EnableDebugLogging = true,
                    Server = octopusServerUrl,
                    ApiKey = octopusApiKey,
                    ReleaseNumber = package.Version,
                    //DefaultPackageVersion = package.Version,
                    DeployTo = octopusReleaseEnvName,
                    TenantTags = new []{$"GlobalTags/{branchName}"}, tag in Octopus
                    ReleaseNotesFile = Paths.RepoDirectory.CombineWithFilePath("ReleaseNotes.md").FullPath,
                    IgnoreExisting = false,
                    DeploymentProgress = true,
                    WaitForDeployment = true,
                    Packages = new Dictionary<string,string>{
                        {package.Name, package.Version},
                        {"Octopus.Deployment.Lib", "2019.904.2"}
                    }

Originally, I wasn’t setting the Packages property above and the release plan was using Latest available source but the same error is raised. In the code example above version is xplicitly set, but it doesn’t help - same error :thinking:

There is no problem if I create the release manually in Octopus with latest package being pushed, but the error manifests when the release is created using the OctoCreateRelease method from the Cake script…

Could this be a bug in that method and the arguments to octo.exe…?

Funally below is my configuration of the addiotinal package and setting the package name reference of AppPkg:

Thank you for your help in advance :blush:

(Emil) #3

SOLVED:
The solution to this error was to use the latest version of OctopusTools:

#tool nuget:?package=OctopusTools&version=6.13.1

in the cake script package reference for the OctopusTools… :roll_eyes:

It appears the error thrown was related to the new functionality for the additional package reference it was not available in the old version of the octo tool.

I hope this helps someone else who gets cought by old version of octo.exe

(Michael Richardson) #4

I’m glad to hear you got it working.
You’re diagnosis is correct :slight_smile: