问题:在Jenkins系统配置中,设置gitlab代码库链接,进行连接测试时报错:sun.security.validator. ValidatorExcep tion: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
分析:查下错误代码,发现错误跟SSL/TSL证书有关。原因大概是gitlab服务器使用的是自签名证书,Java不信任这个CA。
解决办法有两个:1、手动把这个CA添加到Java的信任列表。2、停用gitlab代码库的https,换用http访问。
考虑到公司gitlab只在内网使用,启用HTTPS意义不大,因此采用第二个办法停用HTTPS。具体步骤如下:
1、登录gitlab服务器,执行docker-compose down -v停止gitlab容器。
2、修改docker-compose.yml文件,注释掉https的配置。
代码如下:
web:
image: 'gitlab/gitlab-ce:12.2.4-ce.0'
restart: always
container_name: gitlab
hostname: '10.220.96.205'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://10.220.96.205:8020'
gitlab_rails['gitlab_shell_ssh_port'] = 8022
gitlab_rails['backup_path'] = "/backups"
# external_url 'https://10.220.96.205:8021'
# nginx['listen_port'] = 8021
# nginx['ssl_certificate'] = "/var/opt/gitlab/certs/registry.tpri.com.cn.crt"
# nginx['ssl_certificate_key'] = "/var/opt/gitlab/certs/registry.tpri.com.cn.key"
ports:
- '8020:8020'
- '8022:22'
# - '8021:8021'
volumes:
- '/data/gitlab/config:/etc/gitlab'
- '/data/gitlab/logs:/var/log/gitlab'
- '/data/gitlab/data:/var/opt/gitlab'
- '/mnt/backups:/backups'
- '/etc/localtime:/etc/localtime:ro'
3、执行docker-compose up -d启动gitlab容器,然后重新配置Jenkins的gitlab连接。
网友评论