1

I have a branch name, for example, release-1.1.3, how I can split and extract the version by writing some logic in gitlab-ci file. Is there some method available for it?

before_script

  • export BRANCH_NAME=$CI_COMMIT_REF_NAME

    // here I want to do something to extract the version

  • export Major=BRANCH_NAME.someoperation

  • export Minor=BRANCH_NAME.someoperation
  • export PATCH=BRANCH_NAME.someoperation

any other approaches are also welcome but I required the value in a separate variable which I can pass it to other operations.

I am new to gitlab-ci and working on it, thanks in advance.

Anand Kumar
  • 363
  • 1
  • 5
  • 15
  • You need to split your string Look here: https://stackoverflow.com/questions/18397698/how-to-cut-a-string-after-a-specific-character-in-unix – Sergio Tanaka May 18 '20 at 18:02
  • 1
    Thanks bro.. able to resolve it – Anand Kumar May 19 '20 at 12:13
  • Does this answer your question? [How to cut a string after a specific character in unix](https://stackoverflow.com/questions/18397698/how-to-cut-a-string-after-a-specific-character-in-unix) – Liam Aug 29 '22 at 18:57

1 Answers1

1

Just split your string

You will find some examples here.

How to cut a string after a specific character in unix

Sergio Tanaka
  • 1,325
  • 1
  • 6
  • 18