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 126.96.36.199 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.
Octopus Deploy Command Line Tool, version 188.8.131.52
Handshaking with Octopus server: http://myserver:8082
Handshake successful. Octopus version: 184.108.40.206; 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)
2.Insert(TKey key, TValue value, Boo lean add) at OctopusTools.Importers.ProjectImporter.CheckEnvironmentsExist(List1 envir
at OctopusTools.Importers.ProjectImporter.Import(Dictionary`2 paramDictionary
at OctopusTools.Importers.BaseImporter.Import(String parameters)
at OctopusTools.Commands.ApiCommand.Execute(String commandLineArguments)
at OctopusTools.Program.Main(String args)
Exit code: -3
C:\dev\Octopus\OctopusTools.220.127.116.11\Octo.exe import --server=http://myserver:8082 --apiKey=“MYAPIKEY” --type=“project” --filePath=“C:\dev\Octopus\Export\Project.json”
- 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)
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
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.
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.
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.
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 18.104.22.1684). 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 22.214.171.124 and server 126.96.36.1997.