# Does if expression supports bash sub-commands?

**URL:** <https://forum.buildkite.community/t/does-if-expression-supports-bash-sub-commands/3612>\
**Category:** Pipelines\
**Created:** [March 27, 2024, 12:58am UTC](https://forum.buildkite.community/t/does-if-expression-supports-bash-sub-commands/3612 "2024-03-27T00:58:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![muratgozel](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@muratgozel](https://forum.buildkite.community/u/muratgozel)\
**Post date:** [March 27, 2024, 12:58am UTC](https://forum.buildkite.community/t/does-if-expression-supports-bash-sub-commands/3612/1 "2024-03-27T00:58:06Z")

</div>

I want my pipelines to trigger only when certain type of commit happens and wonder if a simple one liner if expression like the one below can do it.

```yaml
steps:
    - label: "Deploy ... To ..."
      if: $$(build.message | conventional-commits-parser | jq '.[0].type') =~ (feat|fix|perf)
      command: |
          pnpm install --frozen-lockfile --prod=false

```

The expression works inside a sample shell file but not in buildkite environment. It raises:

```log
Error parsing `if` expression: Unexpected `(`:

```

---

<div class="post-metadata">

**Author:** ![benmc](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/benmc/32/1159_2.png) [@benmc](https://forum.buildkite.community/u/benmc)\
**Post date:** [March 27, 2024, 1:07am UTC](https://forum.buildkite.community/t/does-if-expression-supports-bash-sub-commands/3612/2 "2024-03-27T01:07:01Z")

</div>

Hey there @muratgozel!

That’s not possible I’m afraid; the conditions of the `if` are evaluated at upload time, so a command that `evals` cannot be used to determine the run state of a step.

Cheers,

Ben

---

<div class="post-metadata">

**Author:** ![muratgozel](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@muratgozel](https://forum.buildkite.community/u/muratgozel)\
**Post date:** [March 27, 2024, 1:39am UTC](https://forum.buildkite.community/t/does-if-expression-supports-bash-sub-commands/3612/3 "2024-03-27T01:39:36Z")

</div>

Thank you, I undestand now, and came up with an even more simpler solution:

```yaml
      if: build.message =~ /^(feat|fix|perf)/

```

🙂

---

<div class="post-metadata">

**Author:** ![benmc](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/benmc/32/1159_2.png) [@benmc](https://forum.buildkite.community/u/benmc)\
**Post date:** [March 27, 2024, 1:44am UTC](https://forum.buildkite.community/t/does-if-expression-supports-bash-sub-commands/3612/4 "2024-03-27T01:44:47Z")

</div>

Good stuff, @muratgozel! Thanks for sharing that solution for others to see too!
