Travis

Installing Dependencies

Install Packages on Standard Infrastructure #

To install Ubuntu packages that are not included in the standard bionic, focal, jammy or noble distribution, use apt-get in the before_install step of your .travis.yml:

before_install:
  - sudo apt-get -y install libxml2-dev

By default, apt-get update does not run automatically. If you want apt-get update to run automatically on every build, there are two ways to do so. The first is by running apt-get update explicitly in the before_install step, like shown below:

before_install:
  - sudo apt-get update
  - sudo apt-get -y install libxml2-dev

The second way is to use the APT addon:

before_install:
  - sudo apt-get -y install libxml2-dev
addons:
  apt:
    update: true

Do not run apt-get upgrade in your build, as it downloads up to 500MB of packages and significantly extends your build time. Additionally, some packages may fail to update, resulting in a failed build.

Use the -y parameter with apt-get to assume yes to all queries by the apt tools.

Install Packages from a custom APT Repository #

For some packages, you may find an existing repository, which isn’t yet set up on our build environment by default. You can easily add custom repositories and Launchpad PPAs as part of your build.

For example, to install gcc from the ubuntu-toolchain ppa

before_install:
  - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
  - sudo apt-get -q update
  - sudo apt-get -y install gcc-4.8

For repositories not hosted on Launchpad, you need to add a GnuPG key as well.

If you’re installing packages this way, make sure you download the correct version for your environment.

Install Packages without an APT Repository #

For some projects, there may be a Debian/Ubuntu package available, but no corresponding APT repository. These are still easy to install, but require the extra step of downloading.

If you’re installing packages this way, make sure you download the correct version for your environment.

Say your project requires the pngquant tool to compress PNG files, here’s how to download and install the .deb file:

before_install:
  - wget http://pngquant.org/pngquant_1.7.1-1_i386.deb
  - sudo dpkg -i pngquant_1.7.1-1_i386.deb

Install Packages with the APT Addon #

You can also install packages and sources using the APT addon, without running apt-get commands in your before_install script.

If your requirements go beyond the normal installation, please use another method described above.

Add APT Sources #

To add APT sources, you can use one of the following three types of entries: