If: doesn't appear to work in exclude:

If I do

jobs:
  exclude:
  - if: 1 = 1
    os: linux

in a .travis.yml file, Travis does Linux builds.

If, however, I do

jobs:
  exclude:
  - os: linux

What I’m trying to do is to suppress most builds if the branch is coverity_scan, but nothing I tried worked. What must I do here?

And I did

  - gem install travis-conditions

in before_install.

Could you link to build(s) showcasing the problem? Just an excerpt is not enough for diagnostics, it can very well be something else entirely.

This tcpdump build was the one where I first tried this. In this commit I tried suppressing Coverity builds by adding entries like

  - arch: ppc64le
    if: branch == coverity_scan

to the

jobs:
  exclude:
  - arch: ppc64le
    os: osx
  - arch: s390x
    os: osx
  - arch: arm64
    os: osx
  - compiler: gcc
    os: osx

section of .travis.yml to suppress ppc64, s390x, and arm64 coverity_scan builds, because 1) they shouldn’t be necessary (AMD64 builds should suffice) and 2) they got stuck and reported errors.

As that build indicates, it did not suppress the build.

I tried several other things; in this build I tried just doing

jobs:
  exclude:
    - if: 1 = 1

as I inferred it should simply suppress all builds; again, it did not.

Please enable build config validation, or run your config through https://config.travis-ci.com/explore.

I forked your project and I have it enabled, and immediately got an error from it:

root : both matrix and jobs given, matrix overwrites jobs

So your jobs: clause with the excludes is being ignored.

Indeed, when I commented out matrix:, jobs were excluded as expected.

matrix: is now an alias to jobs:, so just merge them under the latter name.

OK, we now have

jobs:
  fast_finish: true
  exclude:
  - arch: ppc64le
    os: osx
  - arch: s390x
    os: osx
  - arch: arm64
    os: osx
  - compiler: gcc
    os: osx
  - if: branch = coverity_scan
    arch: ppc64le
  - if: branch = coverity_scan
    arch: s390x
  - if: branch = coverity_scan
    arch: arm64

cache: ccache

env:
  global:
    # encrypted COVERITY_SCAN_TOKEN from
    # https://scan.coverity.com/projects/<project_id>/submit_build?tab=travis_ci
    - secure: "DwUeukcRGl1vXNZDDt2237zCA58ZzmzWpCkPcb/Hpeh8OvRw1eBZJiu4L8iD2qtY4A/dPDvOeBiml5MF6bVri9Dui1yPkvkvFqIXzbK5CWS6Ye+NgSBNMwqnAjhTMv/x8I4Bvy9IhDGwj/2JXVUvjBddRMLRyr/ag+MDRB1IVAI="
    # Coverity run condition (avoid matrix multiple runs), need customized
    # build script. Need an update if new matrix cases.
    - coverity_scan_run_condition='"$TRAVIS_CPU_ARCH" = amd64 -a "$TRAVIS_OS_NAME" = linux -a "$CC" = gcc -a "$REMOTE" = enable -a "$CMAKE" = no -a "$CRYPTO" = yes -a "$BUILD_LIBPCAP" = yes'
    # Coverity script test mode (if true no uploading, avoid reaching the quota)
    # usual processing: false.
    - coverity_scan_script_test_mode=false
    - MAKEFLAGS='-j 2' # Travis CI VMs come with 2 cores
  matrix:
    # NOTE: REMOTE= is for the libpcap build, which is done with autotools
    # even if we're building tcpdump with CMake.
    # It's irrelevant if we're building tcpdump with the system libpcap.
    - BUILD_LIBPCAP=no  CMAKE=no                 CRYPTO=no
    - BUILD_LIBPCAP=no  CMAKE=no                 CRYPTO=yes
    - BUILD_LIBPCAP=no  CMAKE=yes                CRYPTO=no
    - BUILD_LIBPCAP=no  CMAKE=yes                CRYPTO=yes
    - BUILD_LIBPCAP=yes CMAKE=no  REMOTE=disable CRYPTO=no
    - BUILD_LIBPCAP=yes CMAKE=no  REMOTE=disable CRYPTO=yes
    - BUILD_LIBPCAP=yes CMAKE=no  REMOTE=enable  CRYPTO=no
    - BUILD_LIBPCAP=yes CMAKE=no  REMOTE=enable  CRYPTO=yes
    - BUILD_LIBPCAP=yes CMAKE=yes REMOTE=disable CRYPTO=no
    - BUILD_LIBPCAP=yes CMAKE=yes REMOTE=disable CRYPTO=yes
    - BUILD_LIBPCAP=yes CMAKE=yes REMOTE=enable  CRYPTO=no
    - BUILD_LIBPCAP=yes CMAKE=yes REMOTE=enable  CRYPTO=yes

in tcpdump’s .travis.yml file, but it’s still trying to run builds on, for example, ppc64le, as per this job.

1 Like

Running https://travis-ci.org/github/the-tcpdump-group/tcpdump/builds/689209239/config through https://config.travis-ci.com/explore, I’m not getting any ppc64le jobs.
But they are in the actual build – which is supposed to be using the same expansion logic.

This does seem to be a bug.

Imprint