准备工作
准备两台虚拟机
192.168.1.117 (安装gitlab)
配置建议 4c8g
192.168.1.179(安装gitlab-runner、docker、maven)
配置建议 2c4g
如果装在一台机器,会出现这个问题
https://devops.stackexchange.com/questions/12866/this-job-is-stuck-because-you-dont-have-any-active-runners-online
安装gitlab
参考 https://blog.youkuaiyun.com/SpringHASh/article/details/122032311?spm=1001.2014.3001.5501
安装gitlab-runner
推荐yum安装
添加链接描述
安装gitrunner
# Download the binary for your system
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
chmod +x /usr/local/bin/gitlab-runner
# Create a GitLab CI user
useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
# Install and run as service
gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
gitlab-runner start
#上面两步如果提示 cammand not found,需要配置环境变量,也可以忽略上面两步,直接注册
vim /etc/profile
JAVA_HOME=/opt/jdk1.8.0_211
JAVA_BIN=$JAVA_HOME/bin
JRE_HOME=$JAVA_HOME/jre
JRE_BIN=$JRE_HOME/bin
GIT_RUNNER=/usr/local/bin/git-runner
MAVEN_HOME=/opt/maven-3.3.9/bin
PATH=$JAVA_BIN:$JRE_BIN:$PATH:$GIT_RUNNER:$MAVEN_HOME
export JAVA_HOME JRE_HOME PATH
source /etc/profile
参数来源于
注册 runner
#注册 gitrunner
sudo gitlab-runner register --url http://192.168.1.117/ --registration-token $REGISTRATION_TOKEN
[root@localhost bin]# gitlab-runner register
Runtime platform arch=amd64 os=linux pid=21527 revision=4e1f20da version=13.4.0
Running in system-mode.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://192.168.1.117/
Please enter the gitlab-ci token for this runner:
PwF1sZPX_zsB-xChSKjH
Please enter the gitlab-ci description for this runner:
[localhost.localdomain]: demo
Please enter the gitlab-ci tags for this runner (comma separated):
demo
Registering runner... succeeded runner=PwF1sZPX
Please enter the executor: ssh, virtualbox, parallels, shell, docker-ssh, docker+machine, docker-ssh+machine, kubernetes, custom, docker:
shell
必要时切换权限
sudo su -
加入组权限
usermod -a -G docker gitlab-runner
安装git
yum -y install git
git -version
刷新gitlab页面
安装maven
wget https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
tar -zxvf apache-maven-3.3.9-bin.tar.gz
mv apache-maven-3.3.9 maven-3.3.9
#参考上面的环境变量添加
#配置阿里公共云
vim /opt/maven-3.3.9/conf/settings.xml
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
安装docker
参考 https://blog.youkuaiyun.com/SpringHASh/article/details/121971477?spm=1001.2014.3001.5501
快速获取springboot项目
https://gitee.com/wangLi1997/demo