• [转]gitlab cicd (二)系列之安装git-runner rpm安装方式


    本文转自:https://blog.csdn.net/qq_21816375/article/details/84308748

    本编是继gitlab cicd (一)系列之安装gitlb之后,基于安装gitlab-runner进行CI的部署教程(executor:docker)

    系统

    [root@gitlab-runner-64 ~]# cat /etc/redhat-release
    CentOS Linux release 7.5.1804 (Core)

    安装docker
    请参考安装docker 17.03.2.ce教程

    安装gitlab rpm包

    [root@gitlab-runner-64 ~]# curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
    Detected operating system as centos/7.
    Checking for curl...
    Detected curl...
    Downloading repository file: https://packages.gitlab.com/install/repositories/runner/gitlab-runner/config_file.repo?os=centos&dist=7&source=script
    done.
    Installing pygpgme to verify GPG signatures...
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: mirrors.nwsuaf.edu.cn
    * extras: mirrors.nwsuaf.edu.cn
    * updates: mirrors.nwsuaf.edu.cn
    runner_gitlab-runner-source/signature | 836 B 00:00:00
    Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey
    Importing GPG key 0xE15E78F4:
    Userid : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
    Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4
    From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey
    runner_gitlab-runner-source/signature | 951 B 00:00:00 !!!
    runner_gitlab-runner-source/primary | 175 B 00:00:02
    Package pygpgme-0.3-9.el7.x86_64 already installed and latest version
    Nothing to do
    Installing yum-utils...
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: mirrors.nwsuaf.edu.cn
    * extras: mirrors.nwsuaf.edu.cn
    * updates: mirrors.nwsuaf.edu.cn
    Package yum-utils-1.1.31-46.el7_5.noarch already installed and latest version
    Nothing to do
    Generating yum cache for runner_gitlab-runner...
    Importing GPG key 0xE15E78F4:
    Userid : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
    Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4
    From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey

    The repository is setup! You can now install packages.

    安装gitlab-runner

    root@gitlab-runner-64 ~]# yum install gitlab-runner -y
    1
    启动gitlab-runner

    [root@gitlab-runner-64 ~]# systemctl start gitlab-runner
    [root@gitlab-runner-64 ~]# systemctl status gitlab-runner
    ● gitlab-runner.service - GitLab Runner
    Loaded: loaded (/etc/systemd/system/gitlab-runner.service; enabled; vendor preset: disabled)
    Active: active (running) since Tue 2018-11-20 15:33:55 CST; 1min 15s ago
    Main PID: 27906 (gitlab-runner)
    Memory: 4.9M
    CGroup: /system.slice/gitlab-runner.service
    └─27906 /usr/lib/gitlab-runner/gitlab-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitla...

    Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Running in system-mode.
    Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Running in system-mode.
    Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]:
    Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]:
    Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Configuration loaded builds=0
    Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Configuration loaded builds=0
    Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Listen address not defined, metrics server disabled builds=0
    Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Listen address not defined, metrics server disabled builds=0
    Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Listen address not defined, session server disabled builds=0
    Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Listen address not defined, session server disabled builds=0

    注册gitlab

    [root@gitlab-runner-64 ~]# gitlab-runner register
    Runtime platform arch=amd64 os=linux pid=28891 revision=cf91d5e1 version=11.4.2
    Running in system-mode.

    Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
    http://10.39.47.63
    Please enter the gitlab-ci token for this runner:
    xiwkMztdhy5ipdgpsjHC
    Please enter the gitlab-ci description for this runner:
    [gitlab-runner-64]: gitlab-runner-test
    Please enter the gitlab-ci tags for this runner (comma separated):
    my-tag,another-tag
    Registering runner... succeeded runner=xiwkMztd
    Please enter the executor: docker+machine, kubernetes, docker, parallels, shell, ssh, virtualbox, docker-ssh+machine, docker-ssh:
    docker
    Please enter the default Docker image (e.g. ruby:2.1):
    golang:latest
    Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
    #注册完成之后,gitlab-runner的配置文件会改变
    [root@gitlab-runner-64 ~]# cat /etc/gitlab-runner/config.toml
    concurrent = 1
    check_interval = 0

    [session_server]
    session_timeout = 1800

    [[runners]]
    name = "gitlab-runner-test"
    url = "http://10.39.47.63"
    token = "477e1b6bba858703fd609e7ff991e4"
    executor = "docker"
    [runners.docker]
    tls_verify = false
    image = "golang:latest"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
    [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

    从页面可以查看到


    新建一个项目,项目根目录的.gitlab-ci.yml文件内容如下

    job:
    tags:
    - test-tag ##注意这个是选择指定的runner
    services:
    - php:7
    - node:latest
    - golang:1.10
    image: alpine:3.7
    script:
    - echo '========== hello gitlab-runner'

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11


    把该项目加入刚刚加的gitlab-runner里


    查看执行结果


    end
    参考
    Configuration of your jobs with .gitlab-ci.yml
    runner-register
    安装
    生成token
    ---------------------
    作者:qinzhao168
    来源:CSDN
    原文:https://blog.csdn.net/qq_21816375/article/details/84308748
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    在Ajax中将数组转换成字符串(0517-am)
    Json,Ajax(0516)
    JQUERY的应用
    php 之 PDO数据访问抽象层(0513)
    php 之 房屋租赁练习(0509)
    MySQL 高级查询
    MySQL简单查询
    MySQL语句
    php 之 查询 投票练习(0508)
    linux查看java jdk jre安装路径和设置环境变量
  • 原文地址:https://www.cnblogs.com/freeliver54/p/10560433.html
Copyright © 2020-2023  润新知