0

I have a job defined in a yaml file for gitlab that runs when a tag is made

dev_tests:
stage: tagging

tags:
    - pro1
    - shared

only:
    - tags

except:
    - branches

script:
    - echo running dev tests
    - echo $CI_COMMIT_REF_NAME
    - /usr/local/bin/phpunit -c phpunit_config.xml

The variable $CI_COMMIT_REF_NAME gives me the tag name but I need the branch name as well. Is there a way to get this ? None of the other variables seem to do the job

Thanks

InsaneCat
  • 2,115
  • 5
  • 21
  • 40
GrahamL
  • 243
  • 2
  • 15

1 Answers1

3

I suppose your question is: "Can I get the branch the tag originates from?"

In that case this SO post could be the answer (abstract):

git branch --contains tags/$CI_COMMIT_REF_NAME
Stefan van Gastel
  • 4,330
  • 23
  • 25
  • but gitlab checks out as HEAD detached... which is really not the branch on which the tag is created. this works on local machines where we have correct branch...but on gitlab how to get this command work? – siva Sep 08 '19 at 09:48