# Adding name: changes build jobs

**URL:** <https://travis-ci.community/t/adding-name-changes-build-jobs/2982>\
**Category:** Travis CI Discussions & Feedback\
**Tags:** stages, build-stages, env-vars\
**Created:** [April 11, 2019, 10:04am UTC](https://travis-ci.community/t/adding-name-changes-build-jobs/2982 "2019-04-11T10:04:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hugovk](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/hugovk/32/684_2.png) [@hugovk](https://travis-ci.community/u/hugovk)\
**Post date:** [April 11, 2019, 10:04am UTC](https://travis-ci.community/t/adding-name-changes-build-jobs/2982/1 "2019-04-11T10:04:02Z")

</div>

# Goal

I’m aiming for a build matrix like this:

```auto
Test stage:

    1 Primary tests MY_VAR=abc
    2 Primary tests MY_VAR=def
    3 Other tests

Docker build & push stage:

    4 Build & publish docker images

```

It doesn’t matter if there’s a `MY_VAR` for jobs 3 or 4.

# Without `name:`

I’ve got it working with a [`.travis.yml` something like this](https://github.com/hugovk/test/blob/f5e9945e408737ae39dc91d141979309bc086810/.travis.yml) (the real one is in a private repo):

```auto
language: php

services:
- mysql
- docker

php:
  - 7.3

matrix:
  fast_finish: true

env:
  global:
    - COMPOSER_BIN=$TRAVIS_BUILD_DIR/vendor/bin
    - BLT_DIR=$TRAVIS_BUILD_DIR/vendor/acquia/blt
    - BUILD_DIR=$TRAVIS_BUILD_DIR
    - SIMPLETEST_DB=mysql://drupal:drupal@localhost/drupal
    - SIMPLETEST_BASE_URL=http://127.0.0.1:8888
    - SYMFONY_DEPRECATIONS_HELPER=weak
    - SERVICE_NAME=$(basename $TRAVIS_REPO_SLUG)
    - NGINX_DOCKER_IMAGE=$SERVICE_NAME-nginx:$VERSION_NUMBER
    - PHP_DOCKER_IMAGE=$SERVICE_NAME:$VERSION_NUMBER
    - PATH=~/bin:$PATH
  matrix:
    - MY_VAR=abc
    - MY_VAR=xyz

jdk:
  - oraclejdk8

cache:
  bundler: true
  apt: true
  pip: true
  directories:
  - "$HOME/.composer/cache"
  - "$HOME/.drush/cache"
  - "$HOME/.npm"
  - "$HOME/.nvm"
  - ".rules"

addons:
  ssh_known_hosts:
  # - svn-4786.devcloud.hosting.acquia.com
  chrome: stable

before_install:
  - echo "Primary tests"
  - echo before_install
  - echo before_install
  - echo before_install
  - echo before_install
  - echo before_install
  - echo before_install

stage: "Test"
install:
  - echo "Primary tests"
  - echo install
  - echo install
  - echo install

script:
  - echo "Primary tests"
  - echo script
  - echo script
  - echo script
  - echo script
  - echo script
  - echo script
  - echo script
  - echo script
  - echo script
  - echo script
  - echo script
  - echo script
  - echo script

after_success:
  - echo "Primary tests"
  - echo after_success
  - echo after_success
  - echo after_success
  - echo after_success
  - echo after_success
  - echo after_success
  - echo after_success
  - echo after_success
  - echo after_success

jobs:
  include:
    - stage: "Test"
      install:
        - echo "Secondary tests"
        - echo install

      script:
        - echo "Secondary tests"
        - echo script
        - echo script
        - echo script

      after_success:
        # Don't inherit global after_success
        - echo ""

    - stage: "Docker build & push"
      before_install:
        - echo "Build & publish Docker images"
        - echo before_install
        - echo before_install
        - echo before_install

      script:
        - echo "Build & publish Docker images"
        - echo script
        - echo script

```

 ![image](https://us1.discourse-cdn.com/flex015/uploads/travis_ci/original/2X/c/cae6fb6e09557bb80a352b66ee0b928a2444ecef.png)

[https://travis-ci.org/hugovk/test/builds/518681981](https://travis-ci.org/hugovk/test/builds/518681981)

# With `name:`

However, if I [add `name:` values](https://github.com/hugovk/test/commit/a957c09179f2d259264a469b6338368e04e5e5d2) for clarity in the UI:

```diff
 .travis.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index c047d5a..78d56bd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -55,6 +55,7 @@ before_install:
   - echo before_install
 
 stage: "Test"
+name: "Primary tests"
 install:
   - echo "Primary tests"
   - echo install
@@ -92,6 +93,7 @@ after_success:
 jobs:
   include:
     - stage: "Test"
+ - name: "Secondary tests"
       install:
         - echo "Secondary tests"
         - echo install
@@ -107,6 +109,7 @@ jobs:
         - echo ""
 
     - stage: "Docker build & push"
+ name: "Build & publish Docker images"
       before_install:
         - echo "Build & publish Docker images"
         - echo before_install
-- 
2.21.0

```

It adds an extra, unnecessary build job. The highlighted 319.3 is “Primary tests” with `MY_VAR=abc`, just like 319.1:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/travis_ci/original/2X/9/9ef3c8f2ed0314144130b57cc56f22227a532da7.png)

[https://travis-ci.org/hugovk/test/builds/518686318](https://travis-ci.org/hugovk/test/builds/518686318)

# Questions

Am I missing something, or doing something wrong?

Is this a bug?

Is there another way to label the jobs?

Thank you!

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [April 11, 2019, 12:30pm UTC](https://travis-ci.community/t/adding-name-changes-build-jobs/2982/2 "2019-04-11T12:30:35Z")

</div>

Your `jobs.include` has an extra element in the array because you have a `-` in front of the `name` line you added.

> <https://github.com/hugovk/test/blob/a957c09179f2d259264a469b6338368e04e5e5d2/.travis.yml#L96>

What you want is:

```auto
jobs:
  include:
    - stage: "Test"
      name: "Secondary tests"
      ⋮
    - stage: "Docker build & push"
      name: "Build & publish Docker images"
      ⋮

```

---

<div class="post-metadata">

**Author:** ![hugovk](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/hugovk/32/684_2.png) [@hugovk](https://travis-ci.community/u/hugovk)\
**Post date:** [April 12, 2019, 7:47am UTC](https://travis-ci.community/t/adding-name-changes-build-jobs/2982/3 "2019-04-12T07:47:47Z")

</div>

Thank you for the quick reply, that fixed it!

---

<div class="post-metadata">

**Author:** ![abitrolly](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/abitrolly/32/408_2.png) [@abitrolly](https://travis-ci.community/u/abitrolly)\
**Post date:** [August 2, 2019, 12:54pm UTC](https://travis-ci.community/t/adding-name-changes-build-jobs/2982/4 "2019-08-02T12:54:00Z")

</div>

That’s finally saved my day. I was revisiting [Overriding default job from os matrix](https://travis-ci.community/t/overriding-default-job-from-os-matrix/2328) to understand how to exclude default job, and it appeared that it was not a default job, but an explicit job added by this typo.

```auto
  include:
    - stage: lint
    - python: 3.6
      env: TOXENV=bandit

```

[https://travis-ci.org/release-monitoring/anitya/builds/566916684/config](https://travis-ci.org/release-monitoring/anitya/builds/566916684/config)

To avoid these mistakes, it would help to support indented syntax for stages that could also disable all default jobs.

```auto
stages:
  - lint
    - script: one
  - test
    - script: two
    - script: three
      env: special
  - docker
    - script: docker

```
