3

how can I find out branch name in a job that is running in the pipeline? I tried git branch all i get is
* (detached from <commit number>) master

lila
  • 423
  • 1
  • 4
  • 16

1 Answers1

4

There is a predefined variable called CI_COMMIT_REF_NAME that contains branch name. for more info here

Josh Correia
  • 3,807
  • 3
  • 33
  • 50
lila
  • 423
  • 1
  • 4
  • 16
  • 1
    This is correct.Your can also use ${CI_COMMIT_REF_SLUG} if you want to escape some characters and get a kind of specific name based on the branch name. Check also ${CI_COMMIT_SHA} is you want to distinguish commits inside the same branch. – Mahnu Jun 08 '18 at 10:52