gitlab+gitlab-runner集積CICD

2896 ワード

gitlab+gitlab-runner集積CICD


1 gitlab-runnerインストール

  • 1.1ダウンロード実行ファイル
  • # Linux x86-64
    sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
    
    # Linux x86
    sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386
    
    # Linux arm
    sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm
  • 1.2実行権限
  • を設定する.
    sudo chmod +x /usr/local/bin/gitlab-runner
  • 1.3 GitLab CIユーザ
  • を作成する
    useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
  • 1.4サービス
  • を実行
    gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
    gitlab-runner start

    2 gitlab-runner登録


    2.1 Gitlab登録トークンの取得


    gitlabプロジェクトを開く->設定->CI/CD->Runners設定

    2.2 LINUX登録

  • 実行登録
  • sudo gitlab-runner register
  • GitLab URL
  • を入力
    Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )
    https://xxx.xxx
  • 入力 Runner
  • を登録する.
    Please enter the gitlab-ci token for this runner
    xxx
  • 入力Runner説明
  • Please enter the gitlab-ci description for this runner
    [hostame] my-runner
  • Runnerのtags
  • を入力
    Please enter the gitlab-ci tags for this runner (comma separated):
    my-tag,another-tag
  • 入力Runner実行方式
  • Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
    shell
  • Dockerで実行する場合、you'll be asked for the default image to be used for projects that do not define one in.gitlab-ci.yml:
  • Please enter the Docker image (eg. ruby:2.1):
    alpine:latest

    3リンク成功


    3.1 runnerリスト


    3.2 runner修正


    4编纂gitlab-ci.yml統合

    image: java:8
    stages:
      - build
      - build-pro
    
    #    
    build:
      stage: build
      script:
      - pwd
      - cd project/my_app
      - /usr/local/maven/bin/mvn clean package -P test
      - sh /usr/local/project_deploy_script/app/app_test.sh
      tags:
      - deploy-app
      only:
      - develop
    #    
      stage: build-pro
      script:
      - pwd
      - cd project/my_app
      - /usr/local/maven/bin/mvn clean package -P pro
      - sh /usr/local/project_deploy_script/app/app.sh
      tags:
      - deploy-app
      only:
      - master

    5統合の実行

  • 次の送信コードは統合タスク
  • を実行します.
  • タスクフェーズ
  • 詳細
  • リファレンス

  • Install GitLab Runner manually on GNU/Linux
  • Registering Runners
  • Docker CEミラーソース局
  • © コーヒーを沸かす猫