# "$VAR = \[all\]" custom deployment condition does not work

**URL:** <https://travis-ci.community/t/var-all-custom-deployment-condition-does-not-work/9362>\
**Category:** Deployment\
**Tags:** build-matrix, deploy-conditions\
**Created:** [July 16, 2020, 1:27pm UTC](https://travis-ci.community/t/var-all-custom-deployment-condition-does-not-work/9362 "2020-07-16T13:27:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mschmidt87](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@mschmidt87](https://travis-ci.community/u/mschmidt87)\
**Post date:** [July 16, 2020, 1:27pm UTC](https://travis-ci.community/t/var-all-custom-deployment-condition-does-not-work/9362/1 "2020-07-16T13:27:27Z")

</div>

In my config file, I am defining a build matrix (2 dimensions: python version and an env variable) like so:

```
python:
    - "3.6"
    - "3.7"
    - "3.8"
env:
    - DEP=[all]
    - DEP=[dev]

```

and a deploy stage that should only be run by one specific build. To achieve this, I am specifying the python variable and a condition for the env variable, like so:

```
deploy:
  provider: pages:git
  skip_cleanup: true
  verbose: true
  token: $GITHUB_TOKEN
  edge: true
  local_dir: ./docs/_build/html/
  keep_history: true
  on:
    all_branches: true
    python: 3.8
    condition: $DEP = [all]

```

However, the condition isn’t met for any of my jobs (Message: “Skipping a deployment with the pagesgit provider because a custom condition was not met”), not even for the one with Python 3.8 and $DEP = [all].

See this link for the job:

> **[Travis CI - Test and Deploy with Confidence](https://app.travis-ci.com/github/Happy-Algorithms-League/hal-cgp/builds/708736289)**
>
> Travis CI enables your team to test and ship your apps with confidence. Easily sync your projects with Travis CI and you'll be testing your code in minutes.

What am I doing wrong here? Are the env variables defined above not accessible in the deploy stage? Or is there some syntax error in the condition line?

Additional question: Some of the jobs print out two messages with regards to skipping the deployment:

> Skipping a deployment with the pagesgit provider because this is not on the required runtime  
> Skipping a deployment with the pagesgit provider because a custom condition was not met

What does the first line mean?

---

<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:** [July 16, 2020, 11:38pm UTC](https://travis-ci.community/t/var-all-custom-deployment-condition-does-not-work/9362/2 "2020-07-16T23:38:58Z")

</div>

As per [https://docs.travis-ci.com/user/deployment-v2/conditional#condition](https://docs.travis-ci.com/user/deployment-v2/conditional#condition), a custom condition is evaluated as a Bash conditional expression like this:

```auto
if [[<condition>]]; then <deploy>; fi

```

In double brackets in the `=` comparison, if the right argument is without quotes, it’s treated as an extended regex:

```auto
$ export DEP=[all]
$ (set -x; if [[$DEP = [all] ]]; then echo foo; fi)
+ [[[all] = [all] ]]

$ (set -x; if [[$DEP = "[all]" ]]; then echo foo; fi)
+ [[[all] = \[\a\l\l\] ]]
+ echo foo
foo

```

So you need to quote the right-hand `=` argument in the custom condition.

---

<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:** [July 16, 2020, 11:41pm UTC](https://travis-ci.community/t/var-all-custom-deployment-condition-does-not-work/9362/3 "2020-07-16T23:41:53Z")

</div>

As an aside, heed the build config validation error in [https://travis-ci.org/github/Happy-Algorithms-League/hal-cgp/jobs/708736293/config](https://travis-ci.org/github/Happy-Algorithms-League/hal-cgp/jobs/708736293/config) . Your deployment wouldn’t work even with correct condition due to it.

`Skipping a deployment with the pagesgit provider because this is not on the required runtime` means that the `python: 3.8` condition is not met.

---

<div class="post-metadata">

**Author:** ![mschmidt87](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@mschmidt87](https://travis-ci.community/u/mschmidt87)\
**Post date:** [July 17, 2020, 7:28am UTC](https://travis-ci.community/t/var-all-custom-deployment-condition-does-not-work/9362/4 "2020-07-17T07:28:47Z")

</div>

Thank you very much for the reply, this solved my problem. 👍
