Project Import with Octopus Tools Fails

Hi, I am trying to get a project import working. For some time, I have been manually ‘syncing’ projects between our production Octopus server and a local development instance. This allows me to verify changes before checking-in.

I am using Octopus Deploy version 2.4.10.235 and attempting to perform a project Import using Octopus tools (octo.exe). I am able to Export successfully. However, when I attempt to Import the json project settings, I get an error.

Output

Octopus Deploy Command Line Tool, version 2.4.9.22

Handshaking with Octopus server: http://myserver:8082
Handshake successful. Octopus version: 2.4.10.235; API version: 3.0.0
Finding importer 'project’
Beginning the import
Export file successfully loaded
Checking that all environments exist
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boo lean add) at OctopusTools.Importers.ProjectImporter.CheckEnvironmentsExist(List1 envir
onmentList)
at OctopusTools.Importers.ProjectImporter.Import(Dictionary`2 paramDictionary
)
at OctopusTools.Importers.BaseImporter.Import(String[] parameters)
at OctopusTools.Commands.ImportCommand.Execute()
at OctopusTools.Commands.ApiCommand.Execute(String[] commandLineArguments)
at OctopusTools.Program.Main(String[] args)
Exit code: -3

Command Text

C:\dev\Octopus\OctopusTools.2.4.9.22\Octo.exe import --server=http://myserver:8082 --apiKey=“MYAPIKEY” --type=“project” --filePath=“C:\dev\Octopus\Export\Project.json”

Notes

  • I have ensured that nuget feeds, variable sets, project groups and environments already exist
  • I assumed this error may have been due to environments existing with the same name, but the tool does correctly error if a required environment does not exist
  • I performed a clean re-install of my local Octopus server, assuming some previous configuratino existed in my RavenDB

Can anyone help? A resolution to this this could be a quite valuable workflow for us!

(fixing formatting from Notes section)

Notes

I have ensured that nuget feeds, variable sets, project groups and environments already exist

I assumed this error may have been due to environments existing with the same name, but the tool does correctly error if a required environment does not exist

I performed a clean re-install of my local Octopus server, assuming some previous configuratino existed in my RavenDB

Hi Marcus,

Sorry about the delay in getting back to you. This looks like a bug so I have created an issue in GitHub


Everything in your process and setup looks correct, but it looks like this is failing if an Environment already exists.

Sorry about the issues caused.
Vanessa

Thanks for your response Vanessa, I look forward to seeing the fix in a new release!

Does the version of OctoTools and Octopus Server have to be exactly matched?

I would like to avoid a server upgrade if possible as we recently went through a migration from v1.6.

Hi Marcus,

The upgrade from 1.6->2.X can be quite a painful and lengthy process. Upgrading from 2.x-2.x is much nicer, and requires less effort.
That being said, no, the command line tool does not have to be matched up. But if it is really out of date it will behave badly or error when corresponding features may not exist in either direction.
Octopus -> Tentacle are the strictest in needing to be matched, and that is only within the current version ie 2.5.x -> 2.5.x They can be slightly out of date with patches and still deploy.

Henrik has confirmed this fix should only be for Octopus-Tools.
Vanessa

So I’m getting this same error with a number of my projects too. I think I was able to pinpoint the issue (with mine at least). So let me know if this sounds similar to your setup.

In my case, my projects have many different variables which are scoped between our environments. If I delete all scoped variables except 1 (i.e. leaving a single scoped variable in the project) then the Import will work. I can add other variables at that point which aren’t scoped to an environment. However, once I try to set the scope on a second variable to my Environments then the Import will fail.

I also tried doing the Export/Import on a single server (v 2.5.7.384). So no version upgrade/mismatch.

Hope this helps!

I am also experiencing this issue on import and can confirm that the import succeeds after I remove the environment scope from most variables, so that each environment is used in no more than one variable scope.

Using OctoTools 2.5.4.3 and server 2.5.8.447.