# If: doesn't appear to work in exclude:

**URL:** <https://travis-ci.community/t/if-doesnt-appear-to-work-in-exclude/8595>\
**Category:** Travis CI Discussions & Feedback\
**Tags:** bug\
**Created:** [May 14, 2020, 11:28am UTC](https://travis-ci.community/t/if-doesnt-appear-to-work-in-exclude/8595 "2020-05-14T11:28:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![guyharris](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/guyharris/32/6000_2.png) [@guyharris](https://travis-ci.community/u/guyharris)\
**Post date:** [May 14, 2020, 11:28am UTC](https://travis-ci.community/t/if-doesnt-appear-to-work-in-exclude/8595/1 "2020-05-14T11:28:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![guyharris](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/guyharris/32/6000_2.png) [@guyharris](https://travis-ci.community/u/guyharris)\
**Post date:** [May 14, 2020, 11:32am UTC](https://travis-ci.community/t/if-doesnt-appear-to-work-in-exclude/8595/2 "2020-05-14T11:32:14Z")

</div>

And I did

```
  - gem install travis-conditions

```

in `before_install`.

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [May 14, 2020, 5:32pm UTC](https://travis-ci.community/t/if-doesnt-appear-to-work-in-exclude/8595/3 "2020-05-14T17:32:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![guyharris](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/guyharris/32/6000_2.png) [@guyharris](https://travis-ci.community/u/guyharris)\
**Post date:** [May 14, 2020, 7:18pm UTC](https://travis-ci.community/t/if-doesnt-appear-to-work-in-exclude/8595/4 "2020-05-14T19:18:41Z")

</div>

[This tcpdump build](https://travis-ci.org/github/the-tcpdump-group/tcpdump/builds/686926320) was the one where I first tried this. In [this commit](https://github.com/the-tcpdump-group/tcpdump/commit/5fd77bf58db4a16ec3989decc50cf18b2fef30f8) 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](https://travis-ci.org/github/the-tcpdump-group/tcpdump/builds/686962013) [I tried just doing](https://github.com/the-tcpdump-group/tcpdump/commit/74941cf9d060745f77a900863a104ca05f21ba3f)

```
jobs:
  exclude:
    - if: 1 = 1

```

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

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [May 14, 2020, 10:51pm UTC](https://travis-ci.community/t/if-doesnt-appear-to-work-in-exclude/8595/5 "2020-05-14T22:51:37Z")

</div>

**Please enable build config validation, or run your config through [https://config.travis-ci.com/explore.](https://config.travis-ci.com/explore.)**

I forked your project and I have it enabled, and [immediately got an error from it](https://travis-ci.org/github/native-api/tcpdump/builds/687224760/config):

> `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](https://travis-ci.org/github/native-api/tcpdump/builds/687226138).

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

---

<div class="post-metadata">

**Author:** ![guyharris](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/guyharris/32/6000_2.png) [@guyharris](https://travis-ci.community/u/guyharris)\
**Post date:** [May 21, 2020, 9:37pm UTC](https://travis-ci.community/t/if-doesnt-appear-to-work-in-exclude/8595/6 "2020-05-21T21:37:32Z")

</div>

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](https://travis-ci.org/github/the-tcpdump-group/tcpdump).

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [May 22, 2020, 12:26am UTC](https://travis-ci.community/t/if-doesnt-appear-to-work-in-exclude/8595/7 "2020-05-22T00:26:11Z")

</div>

Running [https://travis-ci.org/github/the-tcpdump-group/tcpdump/builds/689209239/config](https://travis-ci.org/github/the-tcpdump-group/tcpdump/builds/689209239/config) through [https://config.travis-ci.com/explore](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.
