https://www.cnblogs.com/cjsblog/p/12256843.html
https://www.jianshu.com/p/080a962c35b6
https://www.cnblogs.com/diaomina/p/12830449.html
https://hub.docker.com/r/twang2218/gitlab-ce-zh
https://www.cnblogs.com/zzhaolei/p/11063345.html
gitlib 安装
# docker-componse.yml
version: '3'
services:
gitlab:
image: 'twang2218/gitlab-ce-zh'
restart: unless-stopped
hostname: 'gitlab.example.com'
environment:
TZ: 'Asia/Shanghai'
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://192.168.0.103:9980'
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['gitlab_ssh_host'] = '192.168.0.103'
gitlab_rails['gitlab_shell_ssh_port'] = 9922
# 需要配置到 gitlab.rb 中的配置可以在这里配置,每个配置一行,注意缩进。
# 比如下面的电子邮件的配置:
# gitlab_rails['smtp_enable'] = true
# gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
# gitlab_rails['smtp_port'] = 465
# gitlab_rails['smtp_user_name'] = "xxxx@xx.com"
# gitlab_rails['smtp_password'] = "password"
# gitlab_rails['smtp_authentication'] = "login"
# gitlab_rails['smtp_enable_starttls_auto'] = true
# gitlab_rails['smtp_tls'] = true
# gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com'
ports:
- '9980:9980'
- '9922:22'
volumes:
- /home/gitlab/etc:/etc/gitlab
- /home/gitlab/log:/var/log/gitlab
- /home/gitlab/opt:/var/opt/gitlab
deploy:
placement:
constraints:
- node.hostname == worker1
runner:
image: 'gitlab/gitlab-runner'
container_name: gitlab-runner
restart: always
volumes:
- /home/gitlab/runner:/etc/gitlab-runner
- /var/run/docker.sock:/var/run/docker.sock
deploy:
placement:
constraints:
- node.hostname == worker1
docker exec -it gitlab /bin/bash
# 打开文件
vim /etc/gitlab/gitlab.rb
# 这个文件是全注释掉了的,所以直接在首行添加如下配置
# gitlab访问地址,可以写域名。如果端口不写的话默认为80端口 (图片上拼写错误,正确的是external_url)
external_url 'http://192.168.0.103:9980'
# ssh主机ip
gitlab_rails['gitlab_ssh_host'] = '192.168.0.103'
# ssh连接端口
gitlab_rails['gitlab_shell_ssh_port'] = 9922
:x
gitlab-ctl reconfigure
gitlab-ctl restart
exit;
上传代码
http://192.168.0.103:9980/help/ssh/README#generating-a-new-ssh-key-pair
打开git窗口,cmd窗口是没有办法执行命令的
ssh-keygen -t rsa -C "514840279@qq.com" -b 4096
在windows中找到生成文件 一般在 “C:\Users\Administrator.ssh”
Administrator 是你的系统登录用户名称
复制id_rsa.pub文件中的内容到gitlib的ssh上自己的用户
然后就可以在新建的项目上找到ssh命令 clone 到本地
配置CI 与邮件
http://192.168.0.103:9980/help/ci/quick_start/README
按要求 创建一个 .gitlab-ci.yml
gitlib running 需要在kubernetes 上执行,目前放弃
使用docker swarm 配置gitrunner
https://blog.csdn.net/zhangruhong168/article/details/78924700
# 进入 runner 容器
docker exec -it a446dceb9e4d7bdeeb4660132e628fa833870b0ad63391b058c9aa80758743ca bash
# 注册 runner
gitlab-runner register
# 输入 gitlab 示例的 url
http://192.168.0.103:9980/
# 输入用来注册 runner 的 token
cpisdPjUGYzfoPCs2yHY
# 输入 runner 的描述,随后可在 gitlab 界面中修改
gitlab-ci
# 输入与 runner 绑定的标签(可修改)
gitlab-ci
# 选择 runner 的执行方式(推荐docker)
docker
# 如果选择的执行方式是 docker,会要求填写默认的镜像
alpine:latest
配置玩会在CI中显示runner的信息
https://www.freesion.com/article/3042658032/
打包推送配置
https://blog.csdn.net/zhwillwin/article/details/86776948
代码中创建 ..gitlab-ci.yml
variables: #变量
MAVEN_OPTS: "-Dmaven.repo.local=/home/.m2/repository" #指定maven的存储目录
stages:
- build
build:jdk8:
stage: build
script:
- echo "=============== 开始编译打包任务 ==============="
- mvn clean package -Dmaven.test.skip=true
- cd danyuan-gateway && mvn docker:build -DpushImage
# - cd danyuan-serve && mvn docker:build -DpushImage
artifacts:
paths:
- build/
only:
- master #当有代码合到主干时触发这个job
tags:
- danyuan-tools
image: maven:3.3.9-jdk-8
···
settint.xml 中无法设置私服的maven代理,我估计是因为使用dockerswarm 的关系,应该使用host的网络模式,跟redis一个熊样。
···
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<!-- 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.
# docker 应该是网络不通无法访问 103 runner 必须用host才可以
<mirror>
<id>maven-public</id>
<mirrorOf>central</mirrorOf>
<name>maven-public</name>
<url>http://192.168.0.103:9001/repository/maven-public/</url>
</mirror>
| -->
</mirrors>
当有代码提交操作时候自动触发任务执行
点波关注 系统搭建(docker)