# Struggling to get the right custom condition to get pypi deployment running

**URL:** https://travis-ci.community/t/struggling-to-get-the-right-custom-condition-to-get-pypi-deployment-running/7145
**Category:** Deployment
**Tags:** deploy-conditions
**Created:** [February 8, 2020, 8:33am UTC](https://travis-ci.community/t/struggling-to-get-the-right-custom-condition-to-get-pypi-deployment-running/7145 "2020-02-08T08:33:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ericzolf](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ericzolf/32/3786_2.png) [@ericzolf](https://travis-ci.community/u/ericzolf)
#### Post date: [February 8, 2020, 8:33am UTC](https://travis-ci.community/t/struggling-to-get-the-right-custom-condition-to-get-pypi-deployment-running/7145/1 "2020-02-08T08:33:53Z")

</div>

Even after reading the docs and checking examples, I still don’t know what I’m doing wrong:

- I have a pypi deployment
- it has the condition `condition: $MAKE_STEP =~ ^(bdist_wheel|sdist|bdist_win)$ && tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+((a|b|rc)[0-9])?\.dev[0-9]$`
- the tag is there and is `v1.9.0b1.dev4`
- so I would expect at least `sdist` (the last job in the example) to deploy to PyPI
- I only get `Skipping a deployment with the pypi provider because a custom condition was not met`
- the condition without the `&& tag ...` works as expected so the 2nd condition seems wrong but I don’t get what’s wrong
- I’m slightly confused by the condition documentation which states that `env(MAKE_STEP)` should be used and not `$MAKE_STEP` but it works for me (without the 2nd condition at least)

Any help welcome,  
Eric

Example: [https://travis-ci.org/rdiff-backup/rdiff-backup/builds/647642574](https://travis-ci.org/rdiff-backup/rdiff-backup/builds/647642574)

---

<div class="post-metadata">

### Author: ![ericzolf](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ericzolf/32/3786_2.png) [@ericzolf](https://travis-ci.community/u/ericzolf)
#### Post date: [February 8, 2020, 8:46am UTC](https://travis-ci.community/t/struggling-to-get-the-right-custom-condition-to-get-pypi-deployment-running/7145/2 "2020-02-08T08:46:56Z")

</div>

Changing the condition to `condition: env(MAKE_STEP) IN (bdist_wheel, sdist, bdist_win) AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+((a|b|rc)[0-9])?\.dev[0-9]$/` doesn’t help and even leads to a parsing error:

```auto
/home/travis/.travis/job_stages: line 871: unexpected token `(', conditional binary operator expected
/home/travis/.travis/job_stages: line 871: expected `)'
/home/travis/.travis/job_stages: line 871: syntax error near `(env(M'
/home/travis/.travis/job_stages: line 871: ` if [[(env(MAKE_STEP) IN (bdist_wheel, sdist, bdist_win) AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+((a|b|rc)[0-9])?\.dev[0-9]$/) && ("$TRAVIS_TAG" != "") ]]; then'

```

It looks like I completely misunderstood which syntax applies. I was looking at [https://docs.travis-ci.com/user/conditions-v1](https://docs.travis-ci.com/user/conditions-v1) but it seems not to be the right source… I’m definitely confused…

---

<div class="post-metadata">

### Author: ![ericzolf](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ericzolf/32/3786_2.png) [@ericzolf](https://travis-ci.community/u/ericzolf)
#### Post date: [February 8, 2020, 9:22am UTC](https://travis-ci.community/t/struggling-to-get-the-right-custom-condition-to-get-pypi-deployment-running/7145/3 "2020-02-08T09:22:16Z")

</div>

It looks like the solution was to replace `tag` with `$TRAVIS_TAG` but I don’t understand in which parallel universe compared to the documentation I landed.

---

<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: [February 8, 2020, 1:53pm UTC](https://travis-ci.community/t/struggling-to-get-the-right-custom-condition-to-get-pypi-deployment-running/7145/4 "2020-02-08T13:53:23Z")

</div>

`on:` conditions for deployments don’t use the conditions library and are instead described at [https://docs.travis-ci.com/user/deployment#conditional-releases-with-on](https://docs.travis-ci.com/user/deployment#conditional-releases-with-on).

As it says, the syntax in `on: condition:` is a Bash condition where “`tag`” is not a keyword.
