Use a job-level conditional/if to check command output #25081
-
Hi, I want to skip a job if the last commit message started with a certain string. The best we could come up with so far is to have the following as the first step:
After which we include this condition on every following step:
However, this is verbose and prone to error if we forget the if on any subsequent step. I’ve tried using a job-level conditional to check the output of a command or script, but it doesn’t seem possible within an expression. Maybe someone has other ideas on how to accomplish what I’m trying to do? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Output variable is inside a job. You could not use it in job-level condition. Which trigger event do you use? If you are using on: push , you could get the last commit message in github.event context. You could use next two conditions to filter commit message:
Please see my example: |
Beta Was this translation helpful? Give feedback.
-
Thanks! If I use the last commit message in several different jobs, is it possible to set it in a top-level env and reference it in an expression? I tried accessing it via
as well as
but neither worked. Anyway, this is just for a minor reduction in verbosity. Thanks again! |
Beta Was this translation helpful? Give feedback.
Output variable is inside a job. You could not use it in job-level condition.
Which trigger event do you use? If you are using on: push , you could get the last commit message in github.event context.
You could use next two conditions to filter commit message:
Please see my example: