ItGo.me Focus on IT Recommend

Home > git - How do I execute a job for specific branch/tag on Gitlab CI 5.4+?

git - How do I execute a job for specific branch/tag on Gitlab CI 5.4+?

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1073

2020阿里云最低价产品入口,含代金券(新老用户有优惠),
入口地址https://www.aliyun.com/minisite/goods

Latest CHANGELOG on the Gitlab CI github.com repo states that

  • Job can be branch specific or tag specific or both

Has anyone tried this feature? How would I go about making a build for a specific branch? I have not seen any obvious options for it.

Here is a screenshot of the new Job page view.

  • The Trigger option lets you choose between build for commits, tags or both.
  • AFAIK, and based on the help message, the Tags input is for determining which Runner (or group or them) should run this job, as you can associate arbitrary tags with them. These are not git tags. Am I correct? Regardless, this is rather confusing.

So, where can I configure branch/tag names for any particular job?

In my scenario, what I want to achieve is the following:

  • A push to master should run tests, perform a release and deploy to a production-like server.
  • A Merge Request from any feature branch to master, should just run tests and report coverage.
git gitlab-ci
|
  this question
asked Jan 19 '15 at 14:18 Nicolás Fantone 105 1 10

 | 

2 Answers
2

in GitLab CI 5.2 you can add a condition like

Recommend:git - Change root directory for gitlab CI

and configure the .yml to work with a Maven project. The problem is that I have the folders Domain and Front-end in the root of the repository. Is there a way to change the root so the .yml could be able to find the pom.XML file which is i

if [ "$CI_BUILD_REF_NAME" == "master" ]; then
   //run jobs specific to master branch
fi

or

if [ "$CI_BUILD_REF_NAME" != "master" ]; then
   // skip if not on master branch
    exit 0
fi

|
  this answer
edited Jan 20 '15 at 20:49 answered Jan 20 '15 at 20:42 lorandd 77 7      Ok, that is useful. But, what about the CHANGELOG line I was talking about, then? How can I configure an entire job to run on a single branch? Do I have to write those conditionals in every script? –  Nicolás Fantone Jan 22 '15 at 18:29      Moreover, your approach doesn't seem to be working on Gitlab CI 5.4.0. All my builds end on the very first line: if [ "$CI_BUILD_REF_NAME" == "master" ]; then and do not continue beyond that (even if the branch is, indeed, master) –  Nicolás Fantone Feb 4 '15 at 17:54      UPDATE: I believe this (^) is due to a bug in this version of the CI. I have opened an issue over at their github.com repo. –  Nicolás Fantone Feb 4 '15 at 18:46

 | 

You can do this by specifying the branches under the only: attribute in your gilab-ci.yml:

production:
  script:
    - echo 'hello world'
  only:
    - master

For another example, see here.


|
  this answer
answered Feb 3 at 2:02 ostrokach 2,040 16 26

 | 

Recommend:git - What branch does gitlab CI checkouts

t information is not included in we hook that creates a build in gitlab CI. Likewise, how does it determines which branch to checkout git gitlab-ci share asked Oct 4 '14 at 6:05 Srv19 1,171 3 22 47 add a comment | 1 Answer 1 active oldes

------splitte line----------------------------