I'm aware of for instance -only
that let us running jobs on specific branch or tag.
I'm just wondering whether one can do similar thing with predefined environment variables only.
Well, it's just a matter of curiosity than a real need.
Thanks.
Yes, you can use only:variables:
/except:variables:
or you can use rules:
myjob:
# ...
only:
variables:
- $FOO == "bar"
or with rules:
myjob:
rules:
- if: '$FOO == "bar"'
You can use most of the predefined variables for use in rules:
or only:variables
/except:variables:
.
You can use variables like CI_COMMIT_BRANCH
or CI_COMMIT_TAG
to control when a job runs for particular branches/tags.