Does if expression supports bash sub-commands?

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.

    - 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:

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

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.



1 Like

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

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


1 Like

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