I am currently trying to set up a system in which we have an Octopus Server/Tentacle set up within and isolated testing environment which has purely 1 way access (Computers inside can access outside, but not vice versa). We also have a TeamCity server set up on an Azure account where all the build artifacts are held as .zip not nuget.
Is it possible to pull these artifacts from TeamCity into the Octopus Package Repository to be delivered as .zip (we don’t want to switch to nuget at the moment) via the Octopus REST API or the Octopus UI? We obviously cannot use the TeamCity plug-in to push these packages as the test environment wont allow it.
Any help on the matter would be much appreciated.
P.S. I am on a 12 week summer placement so everything is completely new to me, so if I have missed an obvious solution then I apologise in advance
Thanks for getting in touch! Sorry for the delayed response to this question, hopefully the information below is useful for you.
We would highly recommend against the approach that you are taking, if at all possible it would be preferrable to allow traffic from your TeamCity server to your testing environment. This allows packages to be automatically pushed directly into Octopus’s internal package feed. This is fully supported and does not involve any workarounds or manual processes that may break in future.
If this is not possible for compliance or business reasons we do have a couple of workarounds for you. All of the options listed below will require you to create an API key.
The primary option is to have a script that would pull the files from your external TeamCity server into a staging location on your internal Octopus server, then trigger Octo.exe to push the packages into Octopus.
Octo.exe is available from the Octopus download page under the Command Line heading and is the approved command line wrapper around our API calls. Below is an example Octo.exe command that will push a .ZIP package into the internal Octopus package feed:
C:\> Octo.exe push --package MyPackage.1.0.0.zip --replace-existing --server http://my.octopus.url --apiKey API-XXXXXXXXXXXXXXXX
A quick note here, it is preferable that you only attempt to import packages that are new into Octopus, however the “–replace-existing” switch in the command example that I have provided will gracefully allow imports of existing files if that situation occurs.
The second option that we have is to pull the packages directly into the default Octopus package location:
Once the package(s) (zip files) are in that location you will need to trigger a package re-index so that Octopus is aware that the package exists. This will need to be triggered via the Octopus REST API. As this API call is not easily discoverable we can provide further assistance if this is the approach that you would prefer.
As you can see both of these approaches would involve maintain code external to Otcopus/TeamCity so we would highly recommend allowing packages to be pushed from your TeamCity server if at all possible.
Hope that helps, if there is anything else that you need assistance with please let us know!
The actual test environment is isolated for business reasons unfortunately.
The first option seems like it will work to me so I will try that first, just as a back up though what would the correct call be to re-index the octopus package location?
Thank you for your help.
Below is the powershell script that you will need to execute to trigger a package re-index. Note that it is referencing a previously executed re-index task. To get the task number you will need to manually trigger a re-index task from your Octopus management interface, the trigger is located at Library > Packages > Package Indexing (lower right hand corner).
Once the tasks executes go to the Tasks page, select the just completed re-index task and note the ServerTasks number in the URL.
# You can download this dll from your Octopus Server/Tentacle installation directory or from
Add-Type -Path 'C:\PathTo\Octopus.Client.dll'
$apikey = 'API-XXXXXXXXXXXXXXXXXXX' # Get this from your profile
$octopusURI = 'http://my.Octopus.Server' # Your Octopus Server address
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint($octopusURI, $ApiKey)
$repository = New-Object Octopus.Client.OctopusRepository($endpoint)
$taskId = "ServerTasks-zzz" # Get this from /api/tasks
$task = $repository.Tasks.Get($taskId)
Any questions please let us know,