# Skipping a deployment with the script provider because a custom condition was not met when using a regex

**URL:** <https://travis-ci.community/t/skipping-a-deployment-with-the-script-provider-because-a-custom-condition-was-not-met-when-using-a-regex/11094>\
**Category:** Deployment\
**Created:** [January 27, 2021, 11:58pm UTC](https://travis-ci.community/t/skipping-a-deployment-with-the-script-provider-because-a-custom-condition-was-not-met-when-using-a-regex/11094 "2021-01-27T23:58:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixelwhip](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/pixelwhip/32/6059_2.png) [@pixelwhip](https://travis-ci.community/u/pixelwhip)\
**Post date:** [January 27, 2021, 11:58pm UTC](https://travis-ci.community/t/skipping-a-deployment-with-the-script-provider-because-a-custom-condition-was-not-met-when-using-a-regex/11094/1 "2021-01-27T23:58:19Z")

</div>

I’m having issues trying to run a conditional deployment with a regex. I want all `feature/ **** ` branches to deploy to a branch in the artifact repo. I’m able to deploy `develop` and `master` branches as expected but can’t get the feature regex to match. This is my current config

```auto
deploy:
  - provider: script
    script: ./vendor/bin/px artifact:deploy --no-interaction --no-build-version --branch=ci-raleigh-vendor
    on:
      branch: master
    skip_cleanup: true
  - provider: script
    script: ./vendor/bin/px artifact:deploy --no-interaction --no-build-version --branch=develop
    on:
      branch: develop
    skip_cleanup: true
  - provider: script
    script: ./vendor/bin/px artifact:deploy --no-interaction --no-build-version --branch=$TRAVIS_BRANCH
    on:
      all_branches: true
      condition: $TRAVIS_BRANCH =~ ^feature\/\S+$
    skip_cleanup: true

```

When building and deploying `feature/ABC-123` I get the following results in the log

```auto
Skipping a deployment with the script provider because this branch is not permitted: feature/ABC-123
Skipping a deployment with the script provider because this branch is not permitted: feature/ABC-123
Skipping a deployment with the script provider because a custom condition was not met

```

I would expect the first two to skip, but the last one is not meeting the condition. I’ve run the build in debug mode, installed travis-conditions and was able to test my regex which evaluated to true as expected.

```auto
travis-conditions eval "branch =~ ^feature\/\S+$" --data '{"branch": "feature/ABC-123"}'
true

```

Not sure what else may be happening.

---

<div class="post-metadata">

**Author:** ![pixelwhip](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/pixelwhip/32/6059_2.png) [@pixelwhip](https://travis-ci.community/u/pixelwhip)\
**Post date:** [January 28, 2021, 5:30am UTC](https://travis-ci.community/t/skipping-a-deployment-with-the-script-provider-because-a-custom-condition-was-not-met-when-using-a-regex/11094/2 "2021-01-28T05:30:10Z")

</div>

[quote=“pixelwhip, post:1, topic:11094”]

Setting `edge: true` and making the regex a little more broad seems to have fixed the issue.

```auto
deploy:
...
  - provider: script
    edge: true
    script: ./vendor/bin/px artifact:deploy --no-interaction --no-build-version --branch=$TRAVIS_BRANCH
    on:
      all_branches: true
      condition: $TRAVIS_BRANCH =~ ^feature\/.+$
    cleanup: false

```

---

<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:** [January 28, 2021, 9:59pm UTC](https://travis-ci.community/t/skipping-a-deployment-with-the-script-provider-because-a-custom-condition-was-not-met-when-using-a-regex/11094/3 "2021-01-28T21:59:10Z")

</div>

[`on:` `condition:` is a Bash conditional expression](https://docs.travis-ci.com/user/deployment/#conditional-releases-with-on), unlike `if:` conditions.

Bash’s `=~` operator uses Extended Regex rather than PCRE.

```auto
condition: $TRAVIS_BRANCH =~ ^feature/[^[:space:]]+$

```
