# Travis CI - Set variable based on the value of another one (TCI Enterprise)

**URL:** <https://travis-ci.community/t/travis-ci-set-variable-based-on-the-value-of-another-one-tci-enterprise/13778>\
**Category:** Deployment\
**Created:** [April 20, 2023, 9:01pm UTC](https://travis-ci.community/t/travis-ci-set-variable-based-on-the-value-of-another-one-tci-enterprise/13778 "2023-04-20T21:01:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![howtotalktogirls](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/howtotalktogirls/32/8432_2.png) [@howtotalktogirls](https://travis-ci.community/u/howtotalktogirls)\
**Post date:** [April 20, 2023, 9:01pm UTC](https://travis-ci.community/t/travis-ci-set-variable-based-on-the-value-of-another-one-tci-enterprise/13778/1 "2023-04-20T21:01:20Z")

</div>

I’m on Travis Enterprise and I want to conditionally run some jobs depending on the kind of build, in particular, I want to include additional jobs when the event that triggers the CI is the **push of a tag**.

Looking at the documentation ([here](https://docs.travis-ci.com/user/environment-variables/) about env variables and [here](https://docs.travis-ci.com/user/conditions-v1) about conditions), I was able to do that by using a condition like:

```auto
if: tag IS present

```

and it works fine, but I would like to define a new environment variable like `IS_BUILDING_A_TAG`that is `true` when building a tag and `false` otherwise so that I could rewrite the previous condition like:

```auto
if: env(IS_BUILDING_A_TAG)

```

I tried with:

```auto
env:
 - BUILDING_A_TAG=tag IS present

```

but I get the error `invalid env var` on Travis. Can’t find any docs on this. @Montana, any clue?

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [April 20, 2023, 9:03pm UTC](https://travis-ci.community/t/travis-ci-set-variable-based-on-the-value-of-another-one-tci-enterprise/13778/2 "2023-04-20T21:03:56Z")

</div>

Hi @howtotalktogirls,

In Travis, it’s possible to create different jobs, each with its own set of environment variables. You’d do something like:

```auto
jobs:
  include:
    - if: branch = master
      env: 
      - RESOLVER="nightly"
      - STACKYAML="post.yml"
    - if: NOT (branch = master)
      env:
      - RESOLVER="lts-12.11"
      - STACKYAML="pre.yml"

```

One thing to be aware of is, historically in Travis, multiple jobs are simultaneously true, Travis will launch multiple simultaneous jobs, so if you don’t want a commit to kick off multiple jobs, be careful to make sure that the conditions you set are mutually exclusive, as they are in this case I presented above.
