1、Docker安装Jenkins
docker run -p 8080:8080 -p 3306:3306 -p 50000:5000 --name jenkins -u root -v /mydata/jenkins_home:/var/jenkins_home -v /opt/software/apache-maven-3.6.3:/opt/software/apache-maven-3.6.3 -d jenkins/jenkins:lts
2、Docker安装Gitlab
docker run -d -p 443:443 -p 8800:80 -p 22222:22 --name gitlab --restart always -v /mydata/gitlab/config/:/etc/gitlab -v /mydata/gitlab/logs:/var/log/gitlab -v /mydata/gitlab/data:/var/opt/gitlab --privileged=true gitlab/gitlab-ce:latest
登录有问题,查看管理员密码,参考:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/119927586
3、Jenkins安装插件
- Git plugin
- Gitlab Hook Plugin
安装Gitlab Hook Plugin出错:提示java 11 版本过高。参考:
https://blog.csdn.net/weixin_47804643/article/details/120676740
4、gitlab拉项目问题
4.1 SSH Keys可能过期,但是我配置了两个就成功了,可能是第一个有问题
git@192.168.56.12: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
4.2 ssh://git@xxxx/devops/jenkins-springboot.git
地址有问题【xxxx应该为git的地址】,需要修改gitlab配置文件。参考:
https://www.cnblogs.com/imyjy/p/11425457.html
处理方案: 进入容器: docker exec -it <容器id> /bin/bash 编辑配置文件: vi /etc/gitlab/gitlab.rb 找到 external_url , 取消注释, 并修改为 external_url ‘http://服务器的ip或域名’ 找到 gitlab_rails[‘gitlab_ssh_host’], 取消注释, 并修改为 gitlab_rails[‘gitlab_ssh_host’] = ‘服务器的ip或域名’ 找到gitlab_rails[‘gitlab_shell_ssh_port’] = 22222 保存 更新配置: gitlab-ctl reconfigure [不需要重启容器] 重新启动: gitlab-ctl restart 等待1分钟启动完成后, 再次回到线下查看, 发现地址对了 如果修改完之后起不来了,看下日志:GitLab external URL must include a schema and FQDN, e.g. http://gitlab.example.com/ 解决办法 vi /etc/gitlab/gitlab.rb 将 external_url 'xxx' 改成 external_url= 'xxx' 即可
5、配置钩子
5.1 配置过程
Secret token在高级里可以生成,Enable SSL verification关闭。其他参考:
https://www.cnblogs.com/mumuluo/p/14573995.html
5.2 gitlab钩子响应500
设置分支:
https://blog.csdn.net/qq_42063179/article/details/107816191
|