本文介绍了Gitlab CI:-如何在不依赖于任何系统的Gitlab中创建Shared Runner?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经研究了Gitlab Runner的两种类型,一种是Custom Runner,另一种是Shared Runner.

I have study about the Gitlab Runner which are two types one is Custom Runner and another one is Shared Runner.

我已经使用Custom Runner之类的Custom Runner来创建 Android apk.并且它可以正常工作并创建所需的构建.但是通过这种方式,我遇到了一个问题,这取决于我的系统,这意味着当我的系统打开时,我的Custom Runner正常工作,但是当我的系统关闭时,Gitlab无法执行操作因为这取决于我的系统运行程序.

I have used the Custom Runner like docker in the Gitlab for creating the apk of the Android. 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 my Custom Runner works fine but when my system become off then Gitlab fail to perform operation because it depends on my system runner.

我已阅读了不依赖任何内容的Shared 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 .

请在下面检查我的 .gitlab-ci.yml 文件

Please check my .gitlab-ci.yml file below

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:
    - dev-ci
  script:
    - ./gradlew assembleDevelopment assembleProduction assembleStaging
  artifacts:
    paths:
      - app/build/outputs/

请在Gitlab

推荐答案

注册共享运行程序的步骤:

  • 登录到Gitlab.转到管理区域>> 概述>> 跑步者>> 手动设置共享的运行器
    • Login to Gitlab. Go to Admin Area >> Overview >> Runners >> Set up a shared Runner manually
      • 使用root用户或您安装了runner的用户登录到安装runner的服务器(例如gitlab-runner).在这里,我们使用root用户注册运行程序.运行以下命令:

      • 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/

      (在gitlab中的手动设置共享的运行器下查找网址)

      (Look for the url in the gitlab under Set up a shared Runner manually)

      请为此跑步者输入gitlab-ci令牌: jiRS-3KxGaEdkLo6tToZ

      Please enter the gitlab-ci token for this runner: jiRS-3KxGaEdkLo6tToZ

      ((在手动设置共享的运行器下的gitlab中查找令牌)

      (Look for the token in the gitlab under Set up a shared Runner manually )

      请为此跑步者输入gitlab-ci描述: my-first-shred-runner

      Please enter the gitlab-ci description for this runner: my-first-shred-runner

      (输入跑步者的名字)

      请为此跑步者输入gitlab-ci标签(以逗号分隔): ci-shared,ci-task

      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)

      请输入执行程序:docker-ssh,并行,virtualbox,docker +计算机,kubernetes,自定义,docker,docker-ssh +计算机,shell,ssh: shell

      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.

      您可以在Gitlab中进行验证.转到Gitlab,管理区域>>概述>>跑步者>>手动设置共享的运行程序,您会看到运行程序已注册为名称为 my-first-shred-runner

      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

      在Gitlab中为项目启用Shared Runner的步骤:

      Steps to enable Shared Runner for a project in Gitlab:

      1. 转到Gitlab中的项目.
      2. 然后,在项目页面中,设置>> CI/CD>>跑步者>>共享跑步者
      3. 然后,单击Enable shared runners.现在,您可以将共享运行器用于Gitlab CI/CD.
      4. .gitlab-ci.yml中使用与共享运行程序关联的标签,以便作业将使用共享运行程序运行.
      1. Go to a Project in Gitlab.
      2. Then, in the project page, Settings >> CI/CD >> Runners >> Shared Runners
      3. Then, click on Enable shared runners. Now, you can use the shared runner for Gitlab CI/CD.
      4. Use the tags associated with shared runner in .gitlab-ci.yml, so that the jobs will run using shared runner.

      更改.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/
      
      

      注册特定跑步者的步骤:

      1. 登录到Gitlab.转到项目,然后依次设置>> CI/CD>跑步者>>手动设置特定的运行器
      2. 接下来,按照上述第2步中与注册共享运行程序
      3. 相同的步骤进行操作
      1. Login to Gitlab. Go to the Project and then Settings >> CI/CD >> Runners >> Set up a specific Runner manually
      2. Next, follow the same steps from step 2 as given above for Registering Shared Runner

      这篇关于Gitlab CI:-如何在不依赖于任何系统的Gitlab中创建Shared Runner?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 01:20