gitlab+gitlab-runner集積CICD
2896 ワード
gitlab+gitlab-runner集積CICD
1 gitlab-runnerインストール
# 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
sudo chmod +x /usr/local/bin/gitlab-runner
useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
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
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
Please enter the gitlab-ci description for this runner
[hostame] my-runner
Please enter the gitlab-ci tags for this runner (comma separated):
my-tag,another-tag
Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
shell
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