GitLab CI


  • 広報サイトhttp://xb.exrick.cn
  • オンラインDemohttp://xboot.exrick.cn
  • オープンソース版Githubアドレスhttps://github.com/Exrick/x-boot
  • 開発文書https://www.kancloud.cn/exrick/xboot/1009234
  • 完全版を取得します。http://xpay.exrick.cn/pay?xboot GitLab CI_第1张图片
  • 公式文書:https://docs.gitlab.com/ee/ci/README.html 公式諸言語項目CI例:https://gitlab.com/help/ci/examples/README.md GitLab CIファイルの書き方を勉強します。https://docs.gitlab.com/ee/ci/yaml/README.html GitLab Runnerの設置:https://docs.gitlab.com/runner/install/index.html
    GitLab CI
    全部で2ステップ:1.セットアップGitLab Runner 2.作成提出.gitlab-ci.ymlファイル。設定が完了すると、コミットまたは転送のたびにCIがトリガされます。
    GitLab Runnerの設置と配置
    他のシステムでは非常に詳細な公式文書がインストールされています。以下はLinux環境下のデモのみです。
  • はバイナリファイルをダウンロードします。(ダウンロード速度が遅すぎると、ローカルコピーリンクhttps://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64はダウンロードツールを使ってサンダーダウンロード後にアップロードしたり、他の国内のミラーを探したりします。):
  • # Linux x86-64
    sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
    
  • はそれに実行権限を与えます。
  • sudo chmod +x /usr/local/bin/gitlab-runner
    
  • GigtLab CIユーザを作成する:
  • sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
    
  • インストールしてサービスとして運営する:
  • sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
    sudo gitlab-runner start
    
    停止サービス:sudo gitlab-runner stop
  • GigtLab Runner登録を開始し、以下のコマンドを実行します。
    sudo gitlab-runner register
    
  • あなたのGitLabインスタンスURLを入力してください。
  • このサンプルのデモンストレーションは公式サイトGigtLabの使用に基づいています。GitLabのプライベートライブラリを作って住所を記入すればいいです。
    Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )
    https://gitlab.com
    
  • 取得したトークンを入力してRunnerを登録します。
  • Please enter the gitlab-ci token for this runner
    xxx
    
    GitLab CI_第2张图片
    GitLab CI_第3张图片
  • はRunnerの説明を入力します。後でGigtLabのUIで変更できます。
  • Please enter the gitlab-ci description for this runner
    xboot
    
  • は、Runnerに関連するタグを入力して、後でGitLabのUIで変更できます。カンマ区切り:
  • ラベルの役割は、具体的にどのGitLab Runnerを使用するかを指定するために使用することができます。例えば、サーバ1とサーバ2です。
    Please enter the gitlab-ci tags for this runner (comma separated):
    xboot
    
  • は、Runner実行プログラムを入力します。(Dockerを実行プログラムとして選択すると、デフォルトのミラーを設定するように要求されます。
  • Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
    shell
    
  • セットアップが完了しました。GitLab CI_第4张图片
  • .gitlab-ci.ymlファイルを作成する
  • DEMO例
  • stages:
    - build
    - test
    - deploy
    
    #     
    build:
      stage: build
      #       
      script:
        - echo "    "
        - echo "mvn clean..."
        - echo "    "
    
    #     
    test:
      stage: test
      script:
        - echo "      "
        - echo "java -test..."
        - echo "    "
    
    #     
    deploy:
      stage: deploy
      script:
        - echo "    "
        - echo "mvn install..."
        - echo "    "
    
  • は、このファイルを提出すると、CIラインメニューで実行の段階進捗と結果を見ることができます。GitLab CI_第5张图片
  • は、コンソールに入って、具体的な詳細ログを見ることができます。GitLab CI_第6张图片
  • 部分常用Gitlab YAML説明
    詳細は公式文書を参照してください。https://docs.gitlab.com/ee/ci/yaml/README.html
  • 手動トリガ、キーワードwhen定義はいつから開始しますか?ワンタッチ、オンエアー、alwaysまたはマンツー
  • build:
      #             
      when: manual
      stage: build
    
    QQ20190515-154011@2x.png
  • は、Runnerを指定し、キーワードtagsを用いてRunnerを指定する(同時にRunnerもtagsを設定する)
  • build:
      #   tags   xboot Runner  
      tags: 
        - xboot
      stage: build