zoukankan      html  css  js  c++  java
  • Gitlab搭建以及CI/CD

    1,gitlab runner安装以及配置

    Download and install binary
    # Download the binary for your system
    sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
    
    # Give it permissions to execute
    sudo chmod +x /usr/local/bin/gitlab-runner
    
    # Create a GitLab CI user
    sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
    
    # Install and run as service
    sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
    sudo gitlab-runner start
    Command to register runner
    sudo gitlab-runner register --url https://gitlab.bdynamics.com.cn/ --registration-token $REGISTRATION_TOKEN

    2,指定runner clone仓库的地址 

    sudo vi /etc/gitlab-runner/config.toml
    
    指定 clone_url = "http://127.0.0.1/"

    3,gitlab 安装以及指定https/http方式运行

     sudo vi /etc/gitlab/gitlab.rb

    external_url 'https://gitlab.bdynamics.com.cn'
    ##nginx['ssl_certificate'] = "/home/penglei/opt/bdynamics.com.cn.pem"
    nginx['ssl_certificate'] = "/home/penglei/opt/Nginx/1_bdynamics.com.cn_bundle.crt"
    nginx['ssl_certificate_key'] = "/home/penglei/opt/Nginx/2_bdynamics.com.cn.key"

    sudo gitlab-ctl reconfigure

    sudo gitlab-ctl restart

    nginx配置

    /var/opt/gitlab/nginx/conf 增加  gitlab-http.conf 内容

      listen *:80;
    
    
      server_name gitlab.bdynamics.com.cn;

    然后再 /var/opt/gitlab/nginx/conf/nginx.conf中添加

      include /var/opt/gitlab/nginx/conf/gitlab-http.conf;
      include /var/opt/gitlab/nginx/conf/gitlab-https.conf;

    sudo gitlab-ctl nginx restart  (此时不要sudo gitlab-ctl reconfigure,reconfigure会重写配置 /var/opt/gitlab/nginx/conf/nginx.conf)

    4,gtest 与CI/CD

    CICD配置文件 .gitlab-ci.yml    (script中命令所在目录就是源码的根目录,源码会由gitlab runner自动拉取,stages 也可以定义多个,这样可以把代码静态检查等加入到CI/CD里

    stages:
        - buildtest
    
    buildtest:
        stage: buildtest
        script:
            - rm buildx86 -rf
            - mkdir buildx86
            - cd buildx86
            - cmake ..
            - make -j4
            - make all_test

    项目cmake参考,根目录的cmake

    cmake_minimum_required (VERSION 2.8)
    
    project (my_app)
    
    enable_testing()
    add_custom_target(all_test ${CMAKE_CTEST_COMMAND} -V)
    set_property(GLOBAL PROPERTY ROOT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
    set_property(GLOBAL PROPERTY COMMON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
    
    
    add_executable(my_app ${DIR_SRCS})
    
    target_link_libraries(my_app 
                    pthread
                    dl
                    m
                    )

    测试代码对应的cmake

    aux_source_directory(. DIR_LIB_SRCS)
    ## singleton test
    add_executable(singleton_test test/singleton_test.cpp)
    
    target_link_libraries(singleton_test
                    core_base
                    ${GTEST_LIB}
                    pthread
                    )
    add_test(singleton_test singleton_test
            )

    测试代码示例singleton_test.cpp:

    TEST(singletonTest, create_singleton_test) {
        std::cout << Singleton<TestNoDestroy>::instance().name() << std::endl;;
        std::cout << Singleton<TestDestroy>::instance().name() << std::endl;;
    }

     

  • 相关阅读:
    NX二次开发-UFUN设置显示状态抑制显示UF_DISP_set_display
    NX二次开发-使用NXOPEN C++向导模板做二次开发
    ANTV/G6 怎么按条件自定义节点颜色(Graphin)
    js数组去重及数组对象去重
    vue组件老胡机抽奖(转载)
    Kafka第二节
    Kafka第一节
    更改idea的database数据库连接的ddl格式
    不推荐别的了,IDEA 自带的数据库工具就很牛逼!
    MongoDB 按照时间段查询某个物理机的CPU使用率,按照时间倒序排序,取出最新的5条数据
  • 原文地址:https://www.cnblogs.com/rayfloyd/p/14798381.html
Copyright © 2011-2022 走看看