Deploying directly from CI Build?


Sorry if I’ve missed some documentation somewhere, I’ve been searching for a few hours and read a lot of great posts (many pre-2.0 though), but I haven’t been able to find anything that either supports or denies the ability to be able to Deploy from Octopus directly from a CI build.

We are using TFS 2013 on site (we can use TeamCity if its not possible with TFS directly) with git repositories. We have CI builds that will create nuget packages, but so far I’ve been having to manually create the releases for our dev environment (and then promote to staging / production).

Is there a way to have it automatically create releases, or at least deploy in the back end (all the variables for configs and such are setup in Octopus Deploy so I don’t want to have to set those again somewhere else if possible) on checkin?

Hi John,

Thanks for getting in touch and sorry for the delayed reply.

Creating the release from TFS requires calling Octo.exe - this is a command line tool that you can use to create and deploy Octopus releases. How you call it really depends on how comfortable you are with TFS:

  • You could modify the build workflow to invoke it
  • You could create a custom MSBuild project that calls it using the Exec task
  • You could use a “post-build” event in your project to trigger it

This page has a few links on various approaches - you may have seen them already and they are written against older versions, but the concepts are still the same:

Hope this helps!


It looks like my last reply never got saved correctly :(.

I tried doing both the TFS project and msbuild customizations but couldn’t get either to work correctly. The articles are a bit out of date and I haven’t modified either TFS builds or used MSBuild much directly so I wasn’t able to get them working. I did create a simple powershell script that I call from the tfs build config as a post-test event which is working nicely. I still need to make it not auto deploy if tests fail however.

Are you guys still working on your TFS Plugin? Do you need some testers?

We are loving octopus so far! :slight_smile:

I think I have the same issue as John above.
TFS 2013 is ‘doing the CI thing’ nicely, builds, tests and, with OctoPack, a commandline param of /p:RunOctoPack=true I get a package generated just as expected.
What I’d really like to do is ‘auto-deploy’ to our ‘dev platform / IIS’ so that we have a central point where we can automagically see what the latest build looks like.
Can I do this? Maybe I can knock up a filewatcher which sees the new version and calls a command line util (octo.exe??) to force a deploy against a standard release template?
Does any of that make sense?
I’m thinking its what I consider continuous deployment?

Loving what you’re doing btw,
Or am I working on a new release config each time manually?

Steve, and any others that might be interested, here is the powershell script I created. You need to have it on a sharedrive or somewhere your TFS Build Agents can access, and you need to have octopus deploy’s octo.exe installed at C:\Octopus\Octo.exe on those servers (or update the path in the script)

Update your Post-Test script arguments similar to:

-project YOUR_PROJECT_NAME -verbose

You can also override any of the variables at the top of the script such as the serverApiUrl, apiKey, deployEnv, and releaseNumber if you want, or use the defaults (make sure to set them in the script!).

Update the Post-Test script path to the sharedrive of the script and include the script name (create-release.ps1).

Now you’ll have to modify the 2013 template to not run the post test script if the script fails (or create a new deployment script area) which I haven’t had time to figure out yet, but that should allow you to deploy to your “Dev” Environment whenever you do a build (CI or Manual or however you have it configured).

Put this target in your csproj file.

Works like a charm for me… I’m building it in Visual Studio Online. Note that you need to have the Octo.exe available to you, either somewhere on the build machine or in the source workspace you define in the build definition.

Also @Paul Stovell the link you provided contains outdated articles which in my opinion will only serve to confuse people. I personally spent a good deal of time reading through them before I said “forget this” and came up with the target I posted.

Great suggestion Nicholas. For me I couldn’t install Octo.exe on my TFS server due to restrictions, so I added it as a NuGet package to my private NuGet server, and then accessed it from the packages folder:

<Target Name="AfterOctoPack" AfterTargets="OctoPack" DependsOnTargets="OctoPack" Condition="$(RunOctoPack) == 'true'">
    <Message Text="Creating Release for Deployment: $(MSBuildProjectDirectory)" Importance="high" />
    <Exec Command="$(MSBuildProjectDirectory)\..\packages\OctopusTools.\Octo.exe create-release --server=http://octopusAddress/api --project=&quot;ProjectName&quot; --deployto=Development --apikey=API-1234567890ABCDEFGHIJ" />

I think that the TFS integration section deserves a bit of an update and some more detailed info!

Hi John,

Thanks for your input. What kind of info would you like to see on the TFS integration section? I’d be glad to work on it if its something that would help other users.