首页 > 其他 > 详细

GitLab-Runner安装及使用

时间:2020-01-13 16:38:11      阅读:96      评论:0      收藏:0      [点我收藏+]

Git_Lab CI Setting

  1. 根据该教程本地下载并安装 gitlab-runner.exe

  2. 在GitLab远程仓库页面点击 setting-> CI/CD ->runner Expand ,然后拷贝 Runner setup URL , registration token到第三步输入

  3. install gitlab-runner.exe and register on local PC

    # at the git runner folder
    gitlab-runner.exe install
    gitlab-runner.exe register
       ...enter Runner setup URL
       ...enter registration token
       ...enter runner description
       ...enter runner tag (Unique Identification)
       ...enter script executor(depend on script language)
    ## automatically generate config.toml after success
  4. 修改runner中对应的config.toml

concurrent = 1
check_interval = 0
?
[session_server]
  session_timeout = 1800
?
[[runners]]
  name = " PC_1"
  url = "https://gitlab.test.com/"
  token = "test123456789"
  executor = "shell"
  builds_dir = "E:\\GitLab-Runner\\builds"
  cache_dir = "E:\\GitLab-Runner\\cache"
  environment = ["SCE_PHYRE=E:\\GitLab-Runner\\builds\\test"] #设置runner无法读取的环境变量
  shell = "cmd"  # 配置gitlab-ci.yml script会使用的语言
  [runners.custom_build_dir]
    enabled = true
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  1. 在远程仓库根目录下创建t gitlab-ci.yml 文件

#ex:
compile:
  script:
    - cd /d "D:\test"  # 执行runner命令,自定义
    - echo test
  tags:
    - PC_1 # 选择“gitlab-runner.exe register”中设置的“runner tag”
  variables: 
    GIT_CLEAN_FLAGS: -ffdx -e cache/ # 清空缓存
    GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PROJECT_NAME # 设置仓库下载地址
  1. 配置成功后在本地目录下启动runner

    gitlab-runner.exe run --syslog # 不可关闭当前terminal

注:

  • 修改config.toml、注册runner,需要关闭“gitlab-runner.exe run --syslog”(在当前终端Ctrl+C)

  • 一个gitlab-runner.exe可注册多个项目的runner,但不能过多, 同一台主机可以存在多个gitlab-runner.exe(不同目录,仓库地址也不能冲突)

  • config.toml中的“\”需要使用“\\

CMD

gitlab-runner.exe install
gitlab-runner.exe register
gitlab-runner.exe start
gitlab-runner.exe restart
gitlab-runner.exe stop
?
gitlab-runner.exe run --syslog
?
ssh-keygen -t rsa -C ffxbuild@virtuos.com.cn  # 

.gitlab-ci.yml (Git_lab Code)

# 定义 stages
stages:
    - test 
    - compile
test:
    stage: test
    script:
        - echo test
    tags:
        - PC_1  
    
FFX:
    stage: compile
    script:
        - cd /d "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE"
        - devenv.com "E:\GitLab-Runner\builds\test\test.sln" /rebuild "Release|x64"
    tags:
        - PC_1      
variables: 
    GIT_CLEAN_FLAGS: -ffdx -e cache/ # clear git code
    GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PROJECT_NAME   # code dir

QA:

删除register
  1. 在gitlab->setting->ci->runner->expand 删除对应runner

  2. 本地停掉git_runner

  3. 删除本地runner config.toml

 

 

 

 

 

 

 

GitLab-Runner安装及使用

原文:https://www.cnblogs.com/myanswer/p/12187652.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!