I would like to execute a travis stage only on specific commit message (finally on a text tag in a commit message, but let’s simplify for now). Travis allows conditional execution using
if statement (and I prefer to use that, because of the structure of my travis file). Travis documentation mentions 2 variables that could be used to get commit message:
TRAVIS_COMMIT_MESSAGE I tried using both of them. In these cases:
- stage: Deploy if: commit_message = "deploy" AND type = push - stage: Deploy if: $TRAVIS_COMMIT_MESSAGE = "deploy" AND type = push
the stage is executed always, no matter what is the content of the commit message.
In that case:
- stage: Deploy if: env(TRAVIS_COMMIT_MESSAGE) = "deploy" AND type = push
The stage is never executed, no matter what is the content of the commit message.
I also tried adding
conditions: v1 in the root of the .travis file, but with no effect. It seems like comparison operator is not working as expected (especially in first two cases - how can it always be true if strings are not equal??).
Why is comparing commit message not working as expected?