How can we exclude files from our packages created by the Octopus Deploy build server plug-ins or octo.exe?

packages
build-server
(Bob Walker) #1

Due to various requirements, we must use the custom install directory. It provides an option to exclude files from Purge but it does not have an option to exclude files from package deployment. (for Eg. “.config” files). We use Jenkins for our build server and Octopus plugin to create and release projects. But Jenkins Octopus plugin step “Octopus Deploy: Package application” has no option to exclude files from the package.

How can we stop files from being replaced while packaging and deploying release to a Custom Directory?

(Bob Walker) #3

A little background, all build server plug-ins leverage the Octopus Deploy CLI tool known as octo.exe for a variety of tasks. For packaging an application, it uses the octo.exe pack command.

At the time of this writing, the pack command does not provide an exclude file/folder switch, only an include file/folder switch.

There are a few ways to accomplish this:

Option 1: Leverage output directories and exclude files

Most languages include some sort of “publish” mechanism. By that I mean, the build process will build the application and output the results of the build (.dlls, .js, .html, etc) files to a directory.

It is possible to exclude files during that publishing process:

In this case, the build process would be:

  • Build and publish code to an output directory, files are excluded using the language’s built-in functionality
  • Use Octopus Deploy build server plug-in or octo.exe to package code from output directory

Option 2: Delete files after outputting to output directory

Depending on your language of choice or platform, it might not be possible to automatically exclude files. In that case, you could create and write a script to remove unwanted files. That script would run after the build and publish finishes.

In this case, the build process would be:

  • Build and publish code to an output directory
  • Run a script to remove unwanted files
  • Use Octopus Deploy build server plug-in or octo.exe to package code from output directory

Option 3: Use the include files command switch in octo.exe pack

The include files command switch (--includeFiles) allows you to enter a pattern, such as /bin/*.dll. In this case you’d do the opposite of what you want, only include files you want. This could prove to be quite a bit of work, depending on the number of files/folders you wish to exclude. Your mileage may vary with this option.