I want to trigger a build only if a tag refers to a commit contained in
Fir this purpose, I have a
run step that executes:
if ! git branch --contains $CIRCLE_TAG | grep master > /dev/null; then exit 1; fi
I’m doing this because it’s not possible to make it work solely with CircleCI filters (branches and tags).
It works fine locally for a tag that’s not in
master, but when I run it on CircleCI, the
contains command is listing
I logged the result of
git branch --contains $CIRCLE_TAG on CircleCI, and it prints out this:
* (HEAD detached at 0.5.5) master
I ran the pipeline in
docker:stable-git executors, and the results were the same.
Could this be a bug, or am I missing something?
config.yml I’m using for the tests:
version: 2.1 add_filters: &add_filters filters: branches: ignore: /.*/ tags: only: /.*/ jobs: check_branch: docker: - image: docker:stable-git environment: TERM: xterm-256color steps: - checkout - run: | if ! git branch --contains $CIRCLE_TAG | grep master > /dev/null; then exit 1; fi workflows: version: 2.1 release_pod: jobs: - check_branch: <<: *add_filters