Gitlab CI - Start Shared Runner for normal repos

房东的猫 提交于 2019-12-11 06:02:07

问题


I'm new to Gitlab CI.

I have configured .gitlab-ci.yml file, and using CI Lint it has passed the validation process.

Based on this documentation, I can see a specific runner should be configured on a virtual machine, a VPS, a bare-metal machine, a docker container or even a cluster of containers.

And I can see gitlab has its own shared runners and enabled by default.

When I visit the Pipeline page I can only see the blue Get Started with Pipeline button and when clicked I was redirected to this page.

The "Gitlab CI - How to start Shared Runner" says that Gitlab CI will only run the job for the testing branch, however, none of my git use branch unless for very specific cases. So

The question is how to use this shared runner in my normal (private) repo that has only the single master branch?


回答1:


Shared runners will run for any branch, so for the master branch too (unless you configure otherwise).

Additionally,

  • you can pick-up a specific runner if you define a tag for your job.
  • you can filter if the job will be triggered via only and/or except directives.

For example, following job will trigger for any push, despite the branch:

buildClient:
  stage: buildComponents
  script:
  - echo "Building the client..."

On the other hand, this job will trigger only for push to the develop branch and it will be processed by any available runner with the docker tag:

buildServer:
  stage: buildComponents
  script:
  - echo "Building the server with Docker..."
  only:
  - develop
  tags:
  - docker

According the blue Get Started with Pipeline button: You need to add a .gitlab-ci.yml file to the root of your project and push it to GitLab. This file defines stages and jobs of your build pipeline. Jobs are then picked-up by runners according the given configuration. E.g. simple .gitlab-ci.yml can look like this:

image: alpine:latest

stages:
  - test
  - build

testApp:
  stage: test
  script: echo "Testing..."

buildApp:
  stage: build
  script: echo "Building..."

See Configuration of your jobs with .gitlab-ci.yml in GitLab documentation for more details.



来源:https://stackoverflow.com/questions/53212518/gitlab-ci-start-shared-runner-for-normal-repos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!