Gitlab CI :- 如何在不依赖任何系统的 Gitlab 中创建共享运行程序? [英] Gitlab CI :- How to create the Shared Runner in Gitlab which does not depend on the any system?
问题描述
我研究过Gitlab Runner
,有两种类型,一种是Custom Runner
,另一种是Shared Runner
.
我在 Gitlab
中使用了 Custom Runner
像 docker
来创建 的 apk
>Android
.它工作正常并创建所需的构建.但是通过这种方式,我遇到了一个问题,这取决于我的系统,这意味着当我的系统打开时,我的 Custom Runner
工作正常,但是当我的系统关闭时 Gitlab
无法执行操作,因为它取决于我的系统运行器.
我已经阅读了关于 Shared Runner
的内容,它不依赖任何东西并执行操作.我已经阅读了文档,但没有找到实现它的正确方法.
请检查我下面的.gitlab-ci.yml
文件
图片:jangrewe/gitlab-ci-android阶段:- 建造before_script:- 导出 GRADLE_USER_HOME=$(pwd)/.gradle- chmod +x ./gradlew缓存:密钥:${CI_PROJECT_ID}路径:- .gradle/建造:阶段:构建标签:- 开发-ci脚本:- ./gradlew assembleDevelopment assembleProduction assembleStaging文物:路径:- 应用程序/构建/输出/
请在 Gitlab
Shared Runner
上帮助我注册 Shared Runner 的步骤:
<块引用>先决条件:Gitlab-Runner 应该已经安装.按照此文档
登录到安装了 runner 的服务器,可以是 root 用户,也可以是你安装了 runner 的用户(比如 gitlab-runner).在这里,我们使用 root 用户注册跑步者.运行以下命令:
gitlab-runner 注册
根据您的设置填写以下详细信息:
请输入 gitlab-ci 协调器 URL:
您可以在 Gitlab 中验证相同的内容.转到 Gitlab,管理区域 >>概述 >>跑步者 >>手动设置一个共享的Runner,你可以看到runner已经注册了my-first-shred-runner
在 Gitlab 中为项目启用 Shared Runner 的步骤:
- 转到 Gitlab 中的项目.
- 然后,在项目页面中,设置>>CI/CD >>跑步者 >>共享跑步者
- 然后,点击
Enable shared runners
.现在,您可以使用 Gitlab CI/CD 的共享运行程序. - 在
.gitlab-ci.yml
中使用与共享运行器关联的标签,以便作业将使用共享运行器运行.
更改
中的标签.gitlab-ci.yml
图片:jangrewe/gitlab-ci-android阶段:- 建造before_script:- 导出 GRADLE_USER_HOME=$(pwd)/.gradle- chmod +x ./gradlew缓存:密钥:${CI_PROJECT_ID}路径:- .gradle/建造:阶段:构建标签:- 共享脚本:- ./gradlew assembleDevelopment assembleProduction assembleStaging文物:路径:- 应用程序/构建/输出/
注册特定跑步者的步骤:
- 登录 Gitlab.转到项目,然后设置>>CI/CD >>跑步者 >>手动设置特定的 Runner
- 接下来,按照上面为注册共享运行程序 给出的步骤 2 中的相同步骤操作
I have study about the
Gitlab Runner
which are two types one isCustom Runner
and another one isShared Runner
.I have used the
Custom Runner
likedocker
in theGitlab
for creating theapk
of theAndroid
. And It works fine and create the build which desired. But in this way i am getting one problem is that it depends on my system means when my system is on then myCustom Runner
works fine but when my system become off thenGitlab
fail to perform operation because it depends on my system runner.I have read about the
Shared Runner
which does not depend on anything and perform the operation. I have read the documentation but did not get the proper way to implement it .Please check my
.gitlab-ci.yml
file belowimage: jangrewe/gitlab-ci-android stages: - build before_script: - export GRADLE_USER_HOME=$(pwd)/.gradle - chmod +x ./gradlew cache: key: ${CI_PROJECT_ID} paths: - .gradle/ build: stage: build tags: - dev-ci script: - ./gradlew assembleDevelopment assembleProduction assembleStaging artifacts: paths: - app/build/outputs/
Please help me on the
Shared Runner
of theGitlab
解决方案Steps to register a Shared Runner:
Pre-requisite: Gitlab-Runner should have been installed. Follow this document for Installing Runner
- Login to Gitlab. Go to Admin Area >> Overview >> Runners >> Set up a shared Runner manually
Login to the server where runner is installed, either with root user or the user with which you have installed runner (say gitlab-runner). Here, we are registering the runner using root user. Run the below command:
gitlab-runner register
Fill the following details according to your setup:
Please enter the gitlab-ci coordinator URL: https://example.com/gitlab/
(Look for the url in the gitlab under Set up a shared Runner manually)
Please enter the gitlab-ci token for this runner: jiRS-3KxGaEdkLo6tToZ
(Look for the token in the gitlab under Set up a shared Runner manually )
Please enter the gitlab-ci description for this runner: my-first-shred-runner
(Enter any name for the runner)
Please enter the gitlab-ci tags for this runner (comma separated): ci-shared,ci-task
(Enter any tags you want to associate with the runner)
Please enter the executor: docker-ssh, parallels, virtualbox, docker+machine, kubernetes, custom, docker, docker-ssh+machine, shell, ssh: shell
(Enter the executor you need the runner to use, depending on choice of executor you will get other options to fill. Please go through documents of executors )
Now, you can see the message runner has been registered.
You can verify the same in the Gitlab. Go to Gitlab, Admin Area >> Overview >> Runners >> Set up a shared Runner manually and you can see the runner has been registered with name my-first-shred-runner
Steps to enable Shared Runner for a project in Gitlab:
- Go to a Project in Gitlab.
- Then, in the project page, Settings >> CI/CD >> Runners >> Shared Runners
- Then, click on
Enable shared runners
. Now, you can use the shared runner for Gitlab CI/CD. - Use the tags associated with shared runner in
.gitlab-ci.yml
, so that the jobs will run using shared runner.
Change the tags in
.gitlab-ci.yml
image: jangrewe/gitlab-ci-android stages: - build before_script: - export GRADLE_USER_HOME=$(pwd)/.gradle - chmod +x ./gradlew cache: key: ${CI_PROJECT_ID} paths: - .gradle/ build: stage: build tags: - ci-shared script: - ./gradlew assembleDevelopment assembleProduction assembleStaging artifacts: paths: - app/build/outputs/
Steps to register Specific Runner:
- Login to Gitlab. Go to the Project and then Settings >> CI/CD >> Runners >> Set up a specific Runner manually
- Next, follow the same steps from step 2 as given above for Registering Shared Runner
这篇关于Gitlab CI :- 如何在不依赖任何系统的 Gitlab 中创建共享运行程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!