当前位置: 代码迷 >> 综合 >> docker GitLab-runner CI/CD持续集成
  详细解决方案

docker GitLab-runner CI/CD持续集成

热度:70   发布时间:2024-01-16 11:27:58.0

docker GitLab-runner CI/CD持续集成

  • docker GitLab-runner CI/CD持续集成
    • 机器配置
    • gitlab安装
    • 拉取镜像
    • 创建挂载目录
    • 启动容器
    • 注册gitlab-runner
    • 修改Runner配置文件
    • 配置支持https
      • 拷贝证书
      • 配置docker支持访问gitlab
      • 注册gitlab-runner,指定证书
    • gitlab版本升级
    • 备份及恢复
      • Gitlab备份
      • Gitlab仓库恢复
    • 创建SpringBoot项目测试CICD
      • 项目结构
      • 配置docker
      • 注册runner
      • 修改config.toml挂载目录
      • 修改项目pom.xml,引入docker插件
      • 在项目根目录创建Dockerfile文件
      • 项目根目录创建.gitlab-ci.yml文件
      • 提交代码到gitlab
      • 查看打包结果
    • 安装错误
      • ERROR: Failed to load config stat /etc/gitlab-runner/config.toml: no such file or directory builds=0
      • Using locally found image version due to "if-not-present" pull policy
      • Could not transfer artifact com.jayway.jsonpath:json-path:jar:2.4.0
      • ERROR: Runner http://192.168.0.87:8880/j7jVRMZfo5srqW1TWEgL is not healthy and will be disabled!
      • "Can't close tar writer: io: read/write on closed pipe
      • unable to find valid certification path to requested target
      • on project spring-demo: Exception caught: no basic auth credentials
      • Error response from daemon: Get http://192.168.0.87:8075/v2/: dial tcp 192.168.0.87:8075: connect: connection refused

docker GitLab-runner CI/CD持续集成

CI:持续集成,我们通常使用CI来做一些自动化工作,比如程序的打包,单元测试,部署等,这种构建方式避免了打包环境差异引起的错误,提高了工作效率。Gitlab-CI是Gitlab官方提供的持续集成服务,我们可以在仓库的根目录下新建.gitlab-ci.yml文件,自己定义持续集成流程模板,并且在Gitlab中配置runner,在之后的每次提交合并中将会触发构建,并且可以通过Gitlab的hook, 在代码提交的各个环节自动地完成一系列的构建工作,总之对于一些非复杂性的集成需求,都是可以满足的。

gitlab-runner注册参考官网:
https://docs.gitlab.com/runner/install/docker.html
demo下载地址:https://gitee.com/starsky20/docker-gitlab-cicd.git

机器配置

在这里插入图片描述

gitlab安装

参考上一篇《docker gitlab安装》

拉取镜像

镜像地址:
https://hub.docker.com/r/gitlab/gitlab-runner/tags?page=1&ordering=last_updated
在这里插入图片描述
sudo docker pull gitlab/gitlab-runner:latest
在这里插入图片描述

创建挂载目录

rm -rf /home/data/gitlab-runner/
mkdir -p /home/data/gitlab-runner/{config,data,logs}
chmod 777 -R /home/data/gitlab-runner/
在这里插入图片描述

启动容器

gitlab-runner注册参考官网:https://docs.gitlab.com/runner/install/docker.html
在这里插入图片描述
sudo docker run -dit --name gitlab-runner --restart=always
-v /home/data/gitlab-runner/config:/etc/gitlab-runner
-v /var/run/docker.sock:/var/run/docker.sock
gitlab/gitlab-runner:latest
启动结果:
在这里插入图片描述

注册gitlab-runner

Runner注册步骤:
在这里插入图片描述
首先,在docker容器里执行注册命令:
docker exec -it gitlab-runner /bin/bash
gitlab-runner register
在这里插入图片描述
这里的地址是gitlab配置里的,这里以gitlab中的项目spring-demo为例:
在这里插入图片描述
点击该项目进入后,选择设置-》CICD->runner
在这里插入图片描述
展开runner后可以看到注册runner的地址,和token,这个就是我们需要用的。
在这里插入图片描述
执行注册过程:
在这里插入图片描述

详细步骤如下:

[root@localhost gitlab-runner]# 
#进入gitlab-runner内部
[root@localhost gitlab-runner]# docker exec -it gitlab-runner /bin/bash
#注册gitlab-runner
root@928f47744364:/# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=23 revision=c1edb478 version=14.0.1
Running in system-mode.                            
#输入gitlab项目注册地址 
Enter the GitLab instance URL (for example, https://gitlab.com/):
http://192.168.0.87:8880/
#输入gitlab项目注册token 
Enter the registration token:
9g3JBgtr7rUtWoVW_GMD
#输入描述信息,可以随便输入
Enter a description for the runner:
[928f47744364]: my-runner
#输入标签名称,可以随便输入
Enter tags for the runner (comma-separated):
my-tag,another-tag
Registering runner... succeeded                     runner=9g3JBgtr
#选择执行gitlab-runner的执行程序,因为我用docker实现自动部署,所以输入docker:
Enter an executor: custom, virtualbox, docker-ssh+machine, kubernetes, docker, docker-ssh, parallels, shell, ssh, docker+machine:
docker
#选择docker作为执行程序,需要定义一个默认镜像的名称。这个镜像的名称要在后期的.gitlab-ci.yml(自动化部署配置文件)里用到,根据项目代码语言不同,指定不同的镜像。这里项目是java语言的,就使用官方maven:3-jdk-8镜像
Enter the default Docker image (for example, ruby:2.6):
maven:3-jdk-8
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! 
root@928f47744364:/# 

以上表示spring-demo项目gitlab-runner注册成功,此时到我们项目首页右侧设置—》CI/CD —》Runner就可以看到我们刚注册的my-runner了。如图:
在这里插入图片描述
以上是通过手动一步一步设置,这种操作相对比较麻烦一些,下面我们根据参数指定注册过程需要的数据直接配置:
docker run -dit --name gitlab-runner --restart always
-v /home/data/gitlab-runner/config:/etc/gitlab-runner
-v /var/run/docker.sock:/var/run/docker.sock
gitlab/gitlab-runner register
–non-interactive
–url “http://192.168.0.87:8880/”
–registration-token “9g3JBgtr7rUtWoVW_GMD”
–description “my-runner”
–tag-list “another-tag, my-tag”
–executor “docker”
–docker-image maven:3-jdk-8
–run-untagged=“true”
–locked=“false”
–access-level=“not_protected”
在这里插入图片描述

修改Runner配置文件

修改runner配置文件,因为docker image每次构建都是在独立的container里, maven的 .m2文件并不会被多次构建公用,这里我们可以通过修改gitlab-runner的配置,将maven .m2目录加到volumes中,并增加镜像拉取规则(默认是从远程拉取镜像,这里修改为优先获取本地镜像,不存在时才去远程拉取镜像)。
vim /home/data/gitlab-runner/config/config.toml ,找到volumes配置,修改为如下,分别是挂载了宿主机的docker和配置Maven的缓存,提高效率。

[root@localhost config]# 
[root@localhost config]# vim /home/data/gitlab-runner/config/config.toml 
concurrent = 1
check_interval = 0[session_server]session_timeout = 1800[[runners]]name = "my-runner"url = "http://192.168.0.87:8880/"token = "j7jVRMZfo5srqW1TWEgL"executor = "docker"[runners.custom_build_dir][runners.cache][runners.cache.s3][runners.cache.gcs][runners.cache.azure][runners.docker]
#挂载宿主机的docker和配置Maven的缓存,提高效率
volumes = ["/cache","/var/run/docker.sock:/var/run/docker.sock","/home/.m2/:/.m2/"]tls_verify = falseimage = "maven:3-jdk-8"privileged = truedisable_entrypoint_overwrite = falseoom_kill_disable = falsedisable_cache = false
shm_size = 0

在这里插入图片描述

配置支持https

官网:https://docs.gitlab.com/runner/configuration/tls-self-signed.html
参考文档:https://blog.csdn.net/londa/article/details/94144845

拷贝证书

1、首先通过cp命令将crt文件从gitlab宿主机上拷贝到gitlab-runner容器宿主机 /home/data/gitlab-runner/config/ 目录下。
cp -r ssl /home/data/gitlab-runner/config/
在这里插入图片描述
查看gitlab-runner从gitlab拷贝证书:
证书在gitlab-runner容器的/etc/gitlab-runner目录下,对应的宿主机目录/home/data/gitlab-runner/config/。
在这里插入图片描述

配置docker支持访问gitlab

vim /etc/docker/daemon.json
{
“insecure-registries”:[
“https://192.168.0.87:8443”,#这是gitlab的访问地址
“120.79.51.144:8079”,
“192.168.0.87:8075”,
“192.168.0.87:8076”,
“192.168.0.86:8075”
]
}
{
“registry-mirrors”: [
“http://192.168.0.86:8075”,
“https://192.168.0.86:8075”,
“https://registry.docker-cn.com”,
“https://docker.mirrors.ustc.edu.cn”,
“https://hub-mirror.c.163.com”,
“https://hub.docker.com”,
“https://hub.daocloud.io”
]
}
在这里插入图片描述
配置完成后重启docker服务。
systemctl daemon-reload && systemctl restart docker

登录验证gitlab:
docker login https://192.168.0.87:8443
在这里插入图片描述
注意:这里需要保证gitlab地址(gitlab.rb配置)、项目访问地址(gitlab.yml配置)、nginx地址(nginx.conf)这些全部配置正确,并且访问地址一致才行。具体参考以上gitlab配置https。

测试证书是否有效
通过openssl进行执行命令:
openssl s_client -cert demoCA/sslclientcert.pem -key demoCA/sslclientkey.pem -CAfile demoCA/cacert.pem -tls1_2 -host 127.0.0.1 -port 8443
sudo openssl s_server -cert demoCA/sslservercert.pem -key demoCA/sslserverkey.pem -CAfile demoCA/cacert.pem -tls1_2 -Verify 1 -accept 8443

将crt转为pem:
openssl x509 -in mycert.crt -out mycert.pem -outform PE
将pem转为crt:
openssl x509 -outform der -in full_chain.pem -out your-cert.crt

注册gitlab-runner,指定证书

查看项目url及token.
在这里插入图片描述
执行如下命令:
docker run -it --rm -v /home/data/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
–non-interactive
–url “https://192.168.0.87:8443/”
–registration-token “yfDotLzyHDVBwz71E2CF”
–description “package-runner”
–tag-list “package”
–executor “docker”
–docker-privileged
–docker-image docker:latest
–run-untagged=“true”
–locked=“false”
–access-level=“not_protected”
–tls-ca-file=/etc/gitlab-runner/ssl/server.crt;
以上注册方式可能会注册失败,由于gitlab不同版本区别较大,并且备份不是全量,部分数据不全导致注册异常,可以采用将gitlab挂载目录全部备份,拷贝到新的服务器,重启启动服务,然后还原备份数据即可。

gitlab版本升级

参考文档:
https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations
https://docs.gitlab.com/ee/update/index.html

首先备份一下数据,以防万一
1、进入dokcer 容器gitlab备份数据:
sudo docker exec -i -t gitlab /bin/bash
GitLab 12.2 或更高版本:
sudo gitlab-backup create
GitLab 12.1 及更早版本:
gitlab-rake gitlab:backup:create
备份完成,备份文件在 data/backups 文件夹下。在宿主机挂载目录查看备份数据。
2、停止全部服务: gitlab-ctl stop
3、退出容器: exit
4、停止dokcer容器gitlab: sudo docker stop gitlab
5、再删除容器: sudo docker rm gitlab
6、运行新版本gitlab容器(注意升级版本的选择)
sudo docker run -dit --name gitlab
–hostname 192.168.0.87 -p 8443:443 -p 8880:80 -p 4222:22
-v /home/data/gitlab/conf:/etc/gitlab
-v /home/data/gitlab/logs:/var/log/gitlab
-v /home/data/gitlab/data:/var/opt/gitlab
-v /etc/localtime:/etc/localtime
–restart always --privileged=true
gitlab//gitlab-ce:14.0.5-ce.0:latest
备注:只用修改gitlab版本,挂载目录中的数据不要删除

备份及恢复

参考官网:
https://docs.gitlab.com/ee/raketasks/backup_restore.html#when-the-secrets-file-is-lost
参考文档:https://www.cnblogs.com/breakering/p/9712040.html

Gitlab备份

在这里插入图片描述
gitlab备份比较简单,我们直接使用gitlab本身提供的命令进行备份即可,命令会备份gitlab仓库、数据库、用户、用户组、用户密钥、权限等信息

1、通过gitlab-rake命令备份gitlab
gitlab提供的备份命令为gitlab-rake,备份命令使用如下:
GitLab 12.2 或更高版本:
sudo gitlab-backup create

GitLab 12.1 及更早版本:
gitlab-rake gitlab:backup:create
如果您从源代码安装 GitLab,请使用以下命令:

sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production

如果从 Docker 容器中运行 GitLab,请根据您安装的 GitLab 版本从主机运行备份:
GitLab 12.2 或更高版本:
docker exec -t gitlab-backup create

GitLab 12.1 及更早版本:
docker exec -t gitlab-rake gitlab:backup:create

如果在 Kubernetes 集群上使用GitLab Helm 图表,则可以通过使用 在 GitLab 任务kubectl运行器backup-utilitypod 上运行脚本来运行备份任务。有关更多详细信息,请参阅 备份 GitLab 安装。
kubectl exec -it – backup-utility

与 Kubernetes 的情况类似,如果您扩展了 GitLab 集群以使用多个应用程序服务器,您应该选择一个指定的节点(不会自动扩展)来运行备份 Rake 任务。由于备份 Rake 任务与主 Rails 应用程序紧密耦合,因此这通常是一个节点,您也在该节点上运行 Puma 或 Sidekiq。

示例输出:

Dumping database tables:
- Dumping table events... [DONE]
- Dumping table issues... [DONE]
- Dumping table keys... [DONE]
- Dumping table merge_requests... [DONE]
- Dumping table milestones... [DONE]
- Dumping table namespaces... [DONE]
- Dumping table notes... [DONE]
- Dumping table projects... [DONE]
- Dumping table protected_branches... [DONE]
- Dumping table schema_migrations... [DONE]
- Dumping table services... [DONE]
- Dumping table snippets... [DONE]
- Dumping table taggings... [DONE]
- Dumping table tags... [DONE]
- Dumping table users... [DONE]
- Dumping table users_projects... [DONE]
- Dumping table web_hooks... [DONE]
- Dumping table wikis... [DONE]
Dumping repositories:
- Dumping repository abcd... [DONE]
Creating backup archive: $TIMESTAMP_gitlab_backup.tar [DONE]
Deleting tmp directories...[DONE]
Deleting old backups... [SKIPPING]

在这里插入图片描述
在这里插入图片描述
备份完成后,默认备份文件在/var/opt/gitlab/backups/目录下。如果是通过挂载宿主机目录,则在宿主机目录backups下。

可以修改备份的位置及时间,使用如下命令:

vim /etc/gitlab/gitlab.rb
### Backup Settings
###! Docs: https://docs.gitlab.com/omnibus/settings/backups.html
# gitlab_rails['manage_backup_path'] = true
gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
gitlab_rails['backup_keep_time'] = 604800

在这里插入图片描述
修改上图backup_path的值改变备份数据存储位置,修改backup_keep_time来改变存储数据时间。gitlab备份文件随时间变化越来越多,服务器的磁盘空间也不够大。此时我们就要删除部分旧的备份文件,gitlab也提供了删除旧的备份文件功能。通过backup_keep_time进行配置即可即可,之后使用gitlab-ctl reconfigure使得配置生效。

ps:备份文件的名称1628639264_2021_08_11_14.0.5是此次备份的编号。该编号我们会在后续恢复gitlab数据使用到。

2、定时备份gitlab
如果要使gitlab进行自动备份,我们可以通过crontab命令来实现自动备份。强烈建议使用系统crontab命令,而不是用户crontab。
以实现每天凌晨4点进行一次自动备份为例,系统的crontab配置如下:
vim /etc/crontab
0 4 * * * root /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
然后重启crontab服务,如下:
systemctl restart crond

GitLab 12.1 及更早版本的用户应改用该命令gitlab-rake gitlab:backup:create。

GitLab 12.1 以上的版本使用:
/opt/gitlab/bin/gitlab-backup create

Gitlab仓库恢复

恢复步骤:
Omnibus GitLab 安装的恢复
此过程假设:
您已经安装了与创建备份完全相同的 GitLab Omnibus版本和类型 (CE/EE)。
你sudo gitlab-ctl reconfigure至少跑过一次。
GitLab 正在运行。如果没有,请使用sudo gitlab-ctl start.
首先确保您的备份 tar 文件位于gitlab.rb配置中描述的备份目录中 gitlab_rails[‘backup_path’]。默认值为 /var/opt/gitlab/backups. 它需要归git用户所有。

sudo cp 11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar /var/opt/gitlab/backups/
sudo chown git.git /var/opt/gitlab/backups/11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar

停止连接到数据库的进程。让 GitLab 的其余部分保持运行:

sudo gitlab-ctl stop puma
sudo gitlab-ctl stop sidekiq
# Verify
sudo gitlab-ctl status

接下来,恢复备份,指定要恢复的备份的时间戳:

# This command will overwrite the contents of your GitLab database!
sudo gitlab-backup restore BACKUP=11493107454_2018_04_25_10.6.4-ce

GitLab 12.1 及更早版本的用户应改用该命令gitlab-rake gitlab:backup:restore。

gitlab-rake gitlab:backup:restore没有在您的注册表目录上设置正确的文件系统权限。这是一个已知问题。在 GitLab 12.2 或更高版本中,您可以使用gitlab-backup restore来避免此问题。
如果您的备份 tar 文件和已安装的 GitLab 版本之间存在 GitLab 版本不匹配,则恢复命令将中止并显示错误消息。安装正确的 GitLab 版本,然后重试。
接下来,/etc/gitlab/gitlab-secrets.json如有必要,恢复, 如前所述。

重新配置、重启并检查 GitLab:

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
sudo gitlab-rake gitlab:check SANITIZE=true

在 GitLab 13.1 及更高版本中,检查数据库值可以被解密, 尤其是/etc/gitlab/gitlab-secrets.json在恢复时,或者如果不同的服务器是恢复的目标。
sudo gitlab-rake gitlab:doctor:secrets

还原 Docker 映像和 GitLab Helm 图表安装
对于在 Kubernetes 集群上使用 Docker 映像或 GitLab Helm 图表的 GitLab 安装,还原任务期望还原目录为空。但是,对于 Docker 和 Kubernetes 卷挂载,可能会在卷根目录创建一些系统级目录,例如lost+found 在 Linux 操作系统中找到的目录。这些目录通常归 拥有root,这可能会导致访问权限错误,因为恢复 Rake 任务以git用户身份运行。要恢复 GitLab 安装,用户必须确认恢复目标目录为空。

对于这两种安装类型,备份 tarball 必须位于备份位置(默认位置为/var/opt/gitlab/backups)。

对于 Docker 安装,可以从主机运行恢复任务:

在这里插入代码片
# Stop the processes that are connected to the database
docker exec -it <name of container> gitlab-ctl stop puma
docker exec -it <name of container> gitlab-ctl stop sidekiq# Verify that the processes are all down before continuing
docker exec -it <name of container> gitlab-ctl status# Run the restore
docker exec -it <name of container> gitlab-backup restore BACKUP=11493107454_2018_04_25_10.6.4-ce# Restart the GitLab container
docker restart <name of container># Check GitLab
docker exec -it <name of container> gitlab-rake gitlab:check SANITIZE=true

GitLab 12.1 及更早版本的用户应改用该命令gitlab-rake gitlab:backup:create。

gitlab-rake gitlab:backup:restore没有在您的注册表目录上设置正确的文件系统权限。这是一个已知问题。在 GitLab 12.2 或更高版本中,您可以使用gitlab-backup restore来避免此问题。
GitLab Helm chart 使用不同的过程,记录在 恢复 GitLab Helm 图表安装中

以下是验证gitlab备份的有效性,我们可以把该备份文件复制到已经安装好的新服务器的/home/data/gitlab/data/backups/目录下。然后进行数据恢复,最后访问并查看其数据完整性即可。
通过gitlab备份文件可以恢复gitlab所有的信息,包括仓库、数据库、用户、用户组、用户密钥、权限等信息。

注意:新服务器上的gitlab的版本号必须与创建备份时的gitlab版本号相同,并且安装目录也要相同,否则恢复后由于安装位置不同导致异常。

gitlab数据恢复比较简单,具体步骤如下:
在新服务器上启动一个gitlab服务,版本号需要和备份gitlab一致,安装目录一致。容器安装参考以上《gitlab安装》
在这里插入图片描述

1、将备份数据拷贝到新的gitlab服务宿主机backup目录中。
scp /home/data/gitlab/data/backups/1628639264_2021_08_11_14.0.5_gitlab_backup.tar root@192.168.0.86:/home/data/gitlab/data/backups/
在这里插入图片描述
服务器授权该目录:
chmod 777 -R /home/data/gitlab
cd /home/data/gitlab/data/backups/

2、停止相关数据连接服务
在新服务器上停止gitlab相关数据连接服务,命令如下:
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
在这里插入图片描述
3、恢复gitlab仓库
现在我们要从1628639264_2021_08_11_14.0.5这个备份编号中,恢复数据,命令如下:
docker exec -it gitlab_backup /bin/bash
gitlab-rake gitlab:backup:restore RAILS_ENV=production BACKUP=1628639264_2021_08_11_14.0.5
gitlab-rake gitlab:check SANITIZE=true
在这里插入图片描述
如果出现多个done的信息,说明整个gitlab数据就已经正常恢复完毕。
3、启动gitlab服务
恢复完毕以后,我们现在来启动gitlab服务,使用以下命令:
gitlab-ctl restart
启动完成,重新登录gitlab查看

创建SpringBoot项目测试CICD

以下介绍springboot项目,通过定义dockerfile,gitlab-ci.yml相关打包流程,进行自动打包部署,所有访问以http访问,如果是正式环境,需要以https进行访问配置(htps暂不处理)。

项目结构

在这里插入图片描述

配置docker

由于nexus3私服安装在86机器上,gitlab安装在87机器上,所以在gitlab上提交项目时,上传镜像,运行项目操作会使用到nexus3私服,所以这里需要在87服务器上配置通过docker访问86服务器nexus3服务地址,gitlab和docker安装和配置这里不在说明,参考以上gitlab安装。配置内容如下:

vim /etc/docker/daemon.json 
{
    "insecure-registries":["192.168.0.86:8076","192.168.0.86:8075"]
}
{
    "registry-mirrors": ["https://47.119.120.197:8075","https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://hub-mirror.c.163.com","https://hub.docker.com","https://hub.daocloud.io"]
}

配置完成后重启docker服务
systemctl daemon-reload
systemctl restart docker

重启完成后可以通过docker登录测试访问nexus服务是否正常:
docker login -u admin -p admin123 http://192.168.0.86:8075
在这里插入图片描述
注意:这里需要在86机器上开放docker访问端口2375,否则,在其他机器无法访问86私服。Docker/nexus安装参考上一文章内容。

注册runner

注册runner,主要在gilab-ci.yml定义执行流程使用,以下定义了build、package、deploy三种方式:

docker run -it --rm -v /home/data/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
--non-interactive \
--url "http://192.168.0.87:8880/" \
--registration-token "sNPXWNcFsqBrLXEVFNxi" \
--description "package-runner" \
--tag-list "mvn-package" \
--executor "docker" \
--docker-privileged \
--docker-image docker:latest \
--run-untagged="true" \
--locked="false" \
--access-level="not_protected";docker run -it --rm -v /home/data/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
--non-interactive \
--url "http://192.168.0.87:8880/" \
--registration-token "sNPXWNcFsqBrLXEVFNxi" \
--description "build-runner" \
--tag-list "build" \
--executor "docker" \
--docker-privileged \
--docker-image docker:latest \
--run-untagged="true" \
--locked="false" \
--access-level="not_protected";docker run -it --rm -v /home/data/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
--non-interactive \
--url "http://192.168.0.87:8880/" \
--registration-token "sNPXWNcFsqBrLXEVFNxi" \
--description "deploy-runner" \
--tag-list "deploy" \
--executor "docker" \
--docker-privileged \
--docker-image docker:latest \
--run-untagged="true" \
--locked="false" \
--access-level="not_protected";

在这里插入图片描述

修改config.toml挂载目录

修改/home/data/gitlab-runner/config/config.toml配置文件maven缓存文件目录,将宿主机目录改在到容器中,即修改volumes内容为:
volumes = ["/cache","/var/run/docker.sock:/var/run/docker.sock","/home/.m2/?.m2/"]
将宿主机/home/.m2/目录改在到容器/.m2/目录。

修改项目pom.xml,引入docker插件

1、引入docker-maven打包插件,配置打包相关信息

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.0.1.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.example</groupId><artifactId>spring-demo</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>demo</name><description>Demo project for Spring Boot</description><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version><!-- docker 打包镜像上传配置测试环境--><!--<docker-ip>47.119.120.197</docker-ip><docker-url>https://${docker-ip}:2375</docker-url><registry-url>${docker-ip}:8075</registry-url>--><!-- docker 打包镜像上传配置正式环境--><!-- <docker-ip>120.79.51.144</docker-ip><docker-url>https://${docker-ip}:2375</docker-url><registry-url>${docker-ip}:8075</registry-url>--><!-- docker 打包镜像上传配置本地测试环境--><docker-ip>192.168.0.86</docker-ip><docker-url>http://${docker-ip}:2375</docker-url><registry-url>${docker-ip}:8075</registry-url></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>com.jayway.jsonpath</groupId><artifactId>json-path</artifactId><version>2.4.0</version></dependency></dependencies><build><finalName>${project.artifactId}-${project.version}</finalName><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin><!--docker 打包插件--><plugin><groupId>com.spotify</groupId><artifactId>docker-maven-plugin</artifactId><version>1.2.2</version><!-- <executions><execution><id>build-image</id><phase>package</phase><goals><goal>build</goal></goals></execution></executions>--><configuration><!--打包docker镜像的docker服务器--><dockerHost>${docker-url}</dockerHost><!--镜像名,这里用工程名 --><imageName>${registry-url}/${project.artifactId}:${project.version}</imageName><!--nexus3 hosted 仓库地址--><registryUrl>${registry-url}</registryUrl><!-- ca认证正书--><!--<dockerCertPath>/home/data/gitlab/data/cert</dockerCertPath>--><!--<dockerCertPath>D:\cert\docker</dockerCertPath>--><!--TAG,这里用工程版本号--><imageTags><!-- 指定镜像标签,可以排至多个标签 --><imageTag>${project.version}</imageTag></imageTags><!--是否强制覆盖已有镜像--><forceTags>true</forceTags><!--方式一:1、指定Dockerfile文件所在目录,通过文件执行打包上传nexus私服--><dockerDirectory>src/main/docker</dockerDirectory><!-- 方式二:通过配置命令打包 --><!--<baseImage>java</baseImage><entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>--><resources><resource><targetPath>/</targetPath><directory>${project.build.directory}</directory><include>${project.build.finalName}.jar</include></resource></resources><!-- 运行命令 mvn clean package docker:build 打包并生成docker镜像 --><!-- serverId, 与maven配置文件settings.xml中配置的server.id一致,用于推送镜像执行命令: mvn clean compile package docker:build -DpushImage--><!--<serverId>docker-proxy</serverId>--></configuration></plugin></plugins><!-- 资源目录 --><resources><resource><directory>src/main/resources</directory><includes><include>**/*</include></includes><!-- 资源根目录排除各环境的配置,防止在生成目录中多余其它目录 --><excludes><exclude>bootstrap-dev.yml</exclude><exclude>bootstrap-prod.yml</exclude><exclude>bootstrap-test.yml</exclude></excludes><filtering>true</filtering></resource><!--激活指定文件--><resource><directory>src/main/resources</directory><filtering>true</filtering><includes><include>bootstrap.yml</include></includes></resource><!--打包java目录--><resource><directory>src/main/java</directory><includes><include>**/*.*</include></includes><excludes><exclude>**/*.java</exclude></excludes><filtering>true</filtering></resource><!--打包java目录--><resource><directory>src/main/docker</directory><includes><include>**/*</include></includes><filtering>true</filtering></resource></resources></build><!--分环境打包,命令行指定激活方式优先spring.profiles.active=dev--><profiles><profile><id>dev</id><properties><!--默认激活dev环境--><profileActive>dev</profileActive></properties><activation><activeByDefault>true</activeByDefault></activation></profile><profile><id>test</id><properties><profileActive>test</profileActive></properties></profile><profile><id>prod</id><properties><profileActive>prod</profileActive></properties></profile></profiles></project>

这里我们使用是通过maven插件进行打包,上传镜像。

注意:在docker插件中有一个标签
docker-proxy
该标签使用是为了将打包的镜像上传到该标签指定的私服仓库上,方便其他用户使用。
如果使用了该标签,则需要在maven的settings.xml中配置如下内容:

<server><!-- 私服仓库id,必须和私服中仓库id一致--><id>docker-proxy</id> <!-- 登录私服的用户名,密码-->			<username>admin</username>  <password>admin123</password>  
</server>	

在这里插入图片描述
该标签配置后,通过执行命令:mvn clean compile package docker:build -DpushImage
进行编译,打包,上传镜像到私服。

在项目根目录创建Dockerfile文件

在项目根目录创建Dockerfile文件,可以通过本地创建Dockerfile,然后上次到gitlab上,或者通过gitlab上直接创建也可以,这里我使用gitlab上直接创建,登录gitlab,进入到spring-demo项目中,选择repository->file->new file
在这里插入图片描述
填写文件名为Dockerfile,文件内容,然后点击保存即可
在这里插入图片描述
Dockerfile内容如下:

#指定运行环境
FROM java:8#作者
MAINTAINER wangsh#声明一个挂载点,容器内此路径会对应宿主机的某个文件夹
VOLUME /tmp#复制上下文目录下的target/demo-1.0.0.jar 到容器里
#COPY target/daison-server-1.0.2-SNAPSHOT.jar
ADD target/*.jar spring-demo.jar#bash方式执行,使demo-0.0.1jar可访问
#RUN新建立一层,在其上执行这些命令,执行结束后, commit 这一层的修改,构成新的镜像。
RUN sh -c 'touch /spring-demo.jar'#声明运行时容器提供服务端口,这只是一个声明,在运行时并不会因为这个声明应用就会开启这个端口的服务
EXPOSE 9080#设置环境变量
ENV JAVA_OPTS="-Xmx2048m -Xms2048m"
ENV SERVER_PORT="--server.port=9085"#指定容器启动程序
#方式一:该种字符串拼接方式不支持变量替换,如果需要参数,可以指定写死
#ENTRYPOINT ["sh","-c","java -server -Xmx512m -Xms512m","-Djava.security.egd=file:/dev/./urandom","-jar","/spring-demo.jar"]
#方式二:该种方法支持变量替换,通过docker run -e "JAVA_OPTS=-Xmx2048m -Xms2048m" -p 9090:9090 [容器id]
ENTRYPOINT java -server ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /spring-demo.jar ${SERVER_PORT}

创建完成,本地更新gitlab项目,如下图:
在这里插入图片描述

项目根目录创建.gitlab-ci.yml文件

打开gitlab,进入spring-demo项目中,在项目根目录下创建gitlab-ci.yml相关配置,点击repository->File->选择下拉框-》选择 new file
在这里插入图片描述
创建一个.gitlab-ci.yml 文件,添加内容后,点击提交保存。
在这里插入图片描述
gitlab-ci.yml内容如下:

#之前执行
# before_script:
# - sudo su
# - source /etc/profile#1.因为Runner执行器设置为docker, 所以这里需要指定docker的版本
image: docker:latest#2.必须配置的一些环境变量
variables:MAVEN_OPTS: "-Dmaven.repo.local=/.m2"#私服仓库地址REGISTRY_URL: http://192.168.0.86:8075REGISTRY_USER: adminREGISTRY_PWD: admin123DOCKER_DRIVER: overlay2# docker host,本地可不写DOCKER_HOST: tcp://192.168.0.86:2375# 镜像名称IMAGE_NAME: spring-demo# 镜像名称TAG: 192.168.0.86:8075/spring-demo:0.0.1-SNAPSHOT#3.配置缓存,配置后,maven下载的依赖可以被缓存起来,下次不需要重复去下载了
cache:paths:- .m2/repository#4.配置需要用到的额外的服务。docker:dind,这个貌似是用于在 docker 中运行 docker 的一种东西,在项目的构建中需要
#services:
# - docker:dind#5.stages,这是 Gitlab CI 中的概念,Stages 表示构建阶段,就是一些按序执行的流程,具体执行是依赖于 Jobs 的
stages:
# - build- package- deploy#定义job1
#build:
# stage: build
# image: maven:3-jdk-8
# tags:
# - build
# script:
# - echo "=============== docker build image ==============="
# - mvn clean compile
# only:
# - master#定义job2
package:stage: package# 打包用到了maven, 所有需要拉取maven镜像, 这是我自己构建的阿里云maven私服的maven镜像image: maven:3-jdk-8tags:- mvn-packagescript:- echo "=============== mvn package ==============="- mvn $MAVEN_OPTS clean package -Dmaven.test.skip=true#编译打包镜像,该种是通过docker的maven插件打包生成镜像- mvn clean package docker:build# 只作用在master分支only:- master# 这里可以将maven 打包好的文件传递给下一个 stage ,然后下一步的docker 就可以根据 这个 jar 包 和Dockerfile 构建镜像artifacts:# 指定下过期时间和路径expire_in: 1 dayspaths:- target/*.jar#定义job3
deploy:stage: deploytags:- deployscript:- echo "=============== deploy ==============="
# 登录私服- docker login --username $REGISTRY_USER --password $REGISTRY_PWD $REGISTRY_URL
# - docker login --username admin --password admin123 https://192.168.0.86:8075
# - docker build -t $TAG .#上传镜像- docker push $TAG
# 启动服务,判断服务如果存在,则删除,然后启动服务重启启动- if [ $(docker ps -aq --filter name=$IMAGE_NAME) ]; then docker rm -f $IMAGE_NAME ;fi- docker run -dit --name spring-demo -p 9080:9080 --restart=always $TAGonly:- master

以上定义的gitlab-ci.yml流程是按照docker插件打包方式,dockerfile可以根据pom.xml中docker插件标签dockerDirectory指定dockerfile位置,然后通过maven命令 mvn clean package docker:build打包镜像,然后执行上传镜像到nexus私服,在启动运行容器。

方法二:
该中配置方式通过命令执行编译,打包,上传镜像,启动容器,该中方式不需要docker插件,需要将Dockerfile文件放在项目根目录下,gitlab-ci.yml具体配置如下:

#之前执行
# before_script:
# - sudo su
# - source /etc/profile#1.因为Runner执行器设置为docker, 所以这里需要指定docker的版本
image: docker:latest#2.必须配置的一些环境变量,后续流程会使用到该变量
variables:MAVEN_OPTS: "-Dmaven.repo.local=/.m2"SERVER_IP: 192.168.0.86
# SERVER_IP: 47.119.120.197SERVER_PORT: 8075#私服仓库地址REGISTRY_URL: https://$SERVER_IP:$SERVER_PORTREGISTRY_USER: adminREGISTRY_PWD: admin123DOCKER_DRIVER: overlay2# docker host,本地部署可不写DOCKER_HOST: tcp://$SERVER_IP:2375# 镜像名及版本号IMAGE_NAME: spring-demoIMAGE_VERSION: 0.0.1-SNAPSHOT# 镜像名称TAG: $SERVER_IP:$SERVER_PORT/$IMAGE_NAME:$IMAGE_VERSION#3.配置缓存,配置后,maven下载的依赖可以被缓存起来,下次不需要重复去下载了
cache:paths:- .m2/#4.配置需要用到的额外的服务。docker:dind,这个貌似是用于在 docker 中运行 docker 的一种东西,在项目的构建中需要
#services:
# - docker:dind#5.stages,这是 Gitlab CI 中的概念,Stages 表示构建阶段,就是一些按序执行的流程,具体执行是依赖于 Jobs 的
stages:
# - build- package- deploy#定义job1
#build:
# stage: build
# image: maven:3-jdk-8
# tags:
# - build
# script:
# - echo "=============== docker build image ==============="
# - mvn clean compile
# only:
# - master#定义job2
package:stage: package# 打包用到了maven, 所有需要拉取maven镜像image: maven:3-jdk-8tags:- mvn-packagescript:- echo "=============== mvn package ==============="- mvn $MAVEN_OPTS clean compile package -Dmaven.test.skip=true#编译打包镜像
# - mvn clean compile package docker:build# 只作用在master分支only:- master# 这里可以将maven 打包好的文件传递给下一个 stage ,然后下一步的docker 就可以根据 这个 jar 包 和Dockerfile 构建镜像artifacts:# 指定下过期时间和路径expire_in: 1 dayspaths:- target/*.jar#定义job3
deploy:stage: deploytags:- deployscript:- echo "=============== deploy ==============="#打包生成镜像- docker build -t $TAG .# 登录私服
# - docker login --username admin --password admin123 https://192.168.0.86:8075- docker login --username $REGISTRY_USER --password $REGISTRY_PWD $REGISTRY_URL#上传镜像- docker push $TAG
# 启动服务,判断服务如果存在,则删除,然后启动服务重启启动- if [ $(docker ps -aq --filter name=$IMAGE_NAME) ]; then docker rm -f $IMAGE_NAME ;fi#清空重复镜像- docker image prune -f#清空未使用挂载缓存目录- docker volume prune -f#启动容器- docker run -dit --name $IMAGE_NAME -p 9080:9080 --restart=always $TAGonly:- master

提交代码到gitlab

提交代码到gitlab后,会自动执行.
登录gitlab,进入当前提交项目目录,点击CI/CD->pipelines
在这里插入图片描述
点击正在运行的pipeline查看任务
在这里插入图片描述
可以看到这里有两个任务,一个是打包,一个是部署。
点击任务,查看package执行具体日志:
在这里插入图片描述
详细信息如下:

在这里插入代码片
Running with gitlab-runner 14.0.1 (c1edb478)on package-runner 7tH14pxU
Preparing the "docker" executor
00:17
Using Docker executor with image maven:3-jdk-8 ...
Pulling docker image maven:3-jdk-8 ...
Using docker image sha256:cd13aef18fc44265fad303d5279ba630e30e855422d261f20b905dfff90dd60a for maven:3-jdk-8 with digest maven@sha256:3223f3761a39b432d37d051a2537c52ac04f6b0235ffcd2f5a6caab96cfa541a ...
Preparing environment
00:00
Running on runner-7th14pxu-project-2-concurrent-0 via 647ad32b7320...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/root/spring-demo/.git/
Checking out 12937c30 as master...
Removing target/
Skipping Git submodules setup
Restoring cache
00:01
Checking cache for default-1...
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted. 
Successfully extracted cache
Executing "step_script" stage of the job script
00:31
Using docker image sha256:cd13aef18fc44265fad303d5279ba630e30e855422d261f20b905dfff90dd60a for maven:3-jdk-8 with digest maven@sha256:3223f3761a39b432d37d051a2537c52ac04f6b0235ffcd2f5a6caab96cfa541a ...
$ echo "=============== mvn package ==============="
=============== mvn package  ===============
$ mvn $MAVEN_OPTS clean package -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.example:spring-demo >-----------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ spring-demo ---
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ spring-demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ spring-demo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /builds/root/spring-demo/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ spring-demo ---
[INFO] Not copying test resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ spring-demo ---
[INFO] Not compiling test sources
[INFO] 
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ spring-demo ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ spring-demo ---
[INFO] Building jar: /builds/root/spring-demo/target/spring-demo-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.1.RELEASE:repackage (default) @ spring-demo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.146 s
[INFO] Finished at: 2021-07-22T02:57:40Z
[INFO] ------------------------------------------------------------------------
$ mvn clean package docker:build
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.example:spring-demo >-----------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ spring-demo ---
[INFO] Deleting /builds/root/spring-demo/target
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ spring-demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ spring-demo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /builds/root/spring-demo/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ spring-demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /builds/root/spring-demo/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ spring-demo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /builds/root/spring-demo/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ spring-demo ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.example.demo.DemoApplicationTests
02:57:46.963 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.example.demo.DemoApplicationTests]
02:57:46.979 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
02:57:47.001 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
02:57:47.064 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.example.demo.DemoApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
02:57:47.088 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.example.demo.DemoApplicationTests], using SpringBootContextLoader
02:57:47.096 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.demo.DemoApplicationTests]: class path resource [com/example/demo/DemoApplicationTests-context.xml] does not exist
02:57:47.096 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.demo.DemoApplicationTests]: class path resource [com/example/demo/DemoApplicationTestsContext.groovy] does not exist
02:57:47.096 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.example.demo.DemoApplicationTests]: no resource found for suffixes {
    -context.xml, Context.groovy}.
02:57:47.097 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.example.demo.DemoApplicationTests]: DemoApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
02:57:47.157 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.example.demo.DemoApplicationTests]
02:57:47.163 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding PropertySource 'systemProperties' with lowest search precedence
02:57:47.163 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding PropertySource 'systemEnvironment' with lowest search precedence
02:57:47.164 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [MapPropertySource@1160003871 {
    name='systemProperties', properties={
    java.runtime.name=OpenJDK Runtime Environment, sun.boot.library.path=/usr/local/openjdk-8/jre/lib/amd64, java.vm.version=25.302-b08, java.vm.vendor=Oracle Corporation, java.vendor.url=http://java.oracle.com/, path.separator=:, java.vm.name=OpenJDK 64-Bit Server VM, file.encoding.pkg=sun.io, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/builds/root/spring-demo, java.runtime.version=1.8.0_302-b08, basedir=/builds/root/spring-demo, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.endorsed.dirs=/usr/local/openjdk-8/jre/lib/endorsed, os.arch=amd64, surefire.real.class.path=/builds/root/spring-demo/target/surefire/surefirebooter5714235678873556567.jar, java.io.tmpdir=/tmp, line.separator=
, java.vm.specification.vendor=Oracle Corporation, os.name=Linux, sun.jnu.encoding=UTF-8, java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib, surefire.test.class.path=/builds/root/spring-demo/target/test-classes:/builds/root/spring-demo/target/classes:/.m2/org/springframework/boot/spring-boot-starter-web/2.0.1.RELEASE/spring-boot-starter-web-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter/2.0.1.RELEASE/spring-boot-starter-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot/2.0.1.RELEASE/spring-boot-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-autoconfigure/2.0.1.RELEASE/spring-boot-autoconfigure-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter-logging/2.0.1.RELEASE/spring-boot-starter-logging-2.0.1.RELEASE.jar:/.m2/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/.m2/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/.m2/org/apache/logging/log4j/log4j-to-slf4j/2.10.0/log4j-to-slf4j-2.10.0.jar:/.m2/org/apache/logging/log4j/log4j-api/2.10.0/log4j-api-2.10.0.jar:/.m2/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar:/.m2/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/.m2/org/yaml/snakeyaml/1.19/snakeyaml-1.19.jar:/.m2/org/springframework/boot/spring-boot-starter-json/2.0.1.RELEASE/spring-boot-starter-json-2.0.1.RELEASE.jar:/.m2/com/fasterxml/jackson/core/jackson-databind/2.9.5/jackson-databind-2.9.5.jar:/.m2/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/.m2/com/fasterxml/jackson/core/jackson-core/2.9.5/jackson-core-2.9.5.jar:/.m2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.5/jackson-datatype-jdk8-2.9.5.jar:/.m2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.5/jackson-datatype-jsr310-2.9.5.jar:/.m2/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.5/jackson-module-parameter-names-2.9.5.jar:/.m2/org/springframework/boot/spring-boot-starter-tomcat/2.0.1.RELEASE/spring-boot-starter-tomcat-2.0.1.RELEASE.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-core/8.5.29/tomcat-embed-core-8.5.29.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-el/8.5.29/tomcat-embed-el-8.5.29.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.29/tomcat-embed-websocket-8.5.29.jar:/.m2/org/hibernate/validator/hibernate-validator/6.0.9.Final/hibernate-validator-6.0.9.Final.jar:/.m2/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/.m2/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/.m2/com/fasterxml/classmate/1.3.4/classmate-1.3.4.jar:/.m2/org/springframework/spring-web/5.0.5.RELEASE/spring-web-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-beans/5.0.5.RELEASE/spring-beans-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-webmvc/5.0.5.RELEASE/spring-webmvc-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-aop/5.0.5.RELEASE/spring-aop-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-context/5.0.5.RELEASE/spring-context-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-expression/5.0.5.RELEASE/spring-expression-5.0.5.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter-test/2.0.1.RELEASE/spring-boot-starter-test-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-test/2.0.1.RELEASE/spring-boot-test-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-test-autoconfigure/2.0.1.RELEASE/spring-boot-test-autoconfigure-2.0.1.RELEASE.jar:/.m2/junit/junit/4.12/junit-4.12.jar:/.m2/org/assertj/assertj-core/3.9.1/assertj-core-3.9.1.jar:/.m2/org/mockito/mockito-core/2.15.0/mockito-core-2.15.0.jar:/.m2/net/bytebuddy/byte-buddy/1.7.11/byte-buddy-1.7.11.jar:/.m2/net/bytebuddy/byte-buddy-agent/1.7.11/byte-buddy-agent-1.7.11.jar:/.m2/org/objenesis/objenesis/2.6/objenesis-2.6.jar:/.m2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/.m2/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar:/.m2/org/skyscreamer/jsonassert/1.5.0/jsonassert-1.5.0.jar:/.m2/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar:/.m2/org/springframework/spring-core/5.0.5.RELEASE/spring-core-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-jcl/5.0.5.RELEASE/spring-jcl-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-test/5.0.5.RELEASE/spring-test-5.0.5.RELEASE.jar:/.m2/org/xmlunit/xmlunit-core/2.5.1/xmlunit-core-2.5.1.jar:/.m2/com/jayway/jsonpath/json-path/2.4.0/json-path-2.4.0.jar:/.m2/net/minidev/json-smart/2.3/json-smart-2.3.jar:/.m2/net/minidev/accessors-smart/1.2/accessors-smart-1.2.jar:/.m2/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar:/.m2/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:, java.specification.name=Java Platform API Specification, java.class.version=52.0, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, os.version=3.10.0-1160.el7.x86_64, user.home=/root, user.timezone=Etc/UTC, java.awt.printerjob=sun.print.PSPrinterJob, file.encoding=UTF-8, java.specification.version=1.8, java.class.path=/builds/root/spring-demo/target/test-classes:/builds/root/spring-demo/target/classes:/.m2/org/springframework/boot/spring-boot-starter-web/2.0.1.RELEASE/spring-boot-starter-web-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter/2.0.1.RELEASE/spring-boot-starter-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot/2.0.1.RELEASE/spring-boot-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-autoconfigure/2.0.1.RELEASE/spring-boot-autoconfigure-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter-logging/2.0.1.RELEASE/spring-boot-starter-logging-2.0.1.RELEASE.jar:/.m2/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/.m2/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/.m2/org/apache/logging/log4j/log4j-to-slf4j/2.10.0/log4j-to-slf4j-2.10.0.jar:/.m2/org/apache/logging/log4j/log4j-api/2.10.0/log4j-api-2.10.0.jar:/.m2/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar:/.m2/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/.m2/org/yaml/snakeyaml/1.19/snakeyaml-1.19.jar:/.m2/org/springframework/boot/spring-boot-starter-json/2.0.1.RELEASE/spring-boot-starter-json-2.0.1.RELEASE.jar:/.m2/com/fasterxml/jackson/core/jackson-databind/2.9.5/jackson-databind-2.9.5.jar:/.m2/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/.m2/com/fasterxml/jackson/core/jackson-core/2.9.5/jackson-core-2.9.5.jar:/.m2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.5/jackson-datatype-jdk8-2.9.5.jar:/.m2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.5/jackson-datatype-jsr310-2.9.5.jar:/.m2/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.5/jackson-module-parameter-names-2.9.5.jar:/.m2/org/springframework/boot/spring-boot-starter-tomcat/2.0.1.RELEASE/spring-boot-starter-tomcat-2.0.1.RELEASE.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-core/8.5.29/tomcat-embed-core-8.5.29.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-el/8.5.29/tomcat-embed-el-8.5.29.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.29/tomcat-embed-websocket-8.5.29.jar:/.m2/org/hibernate/validator/hibernate-validator/6.0.9.Final/hibernate-validator-6.0.9.Final.jar:/.m2/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/.m2/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/.m2/com/fasterxml/classmate/1.3.4/classmate-1.3.4.jar:/.m2/org/springframework/spring-web/5.0.5.RELEASE/spring-web-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-beans/5.0.5.RELEASE/spring-beans-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-webmvc/5.0.5.RELEASE/spring-webmvc-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-aop/5.0.5.RELEASE/spring-aop-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-context/5.0.5.RELEASE/spring-context-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-expression/5.0.5.RELEASE/spring-expression-5.0.5.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter-test/2.0.1.RELEASE/spring-boot-starter-test-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-test/2.0.1.RELEASE/spring-boot-test-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-test-autoconfigure/2.0.1.RELEASE/spring-boot-test-autoconfigure-2.0.1.RELEASE.jar:/.m2/junit/junit/4.12/junit-4.12.jar:/.m2/org/assertj/assertj-core/3.9.1/assertj-core-3.9.1.jar:/.m2/org/mockito/mockito-core/2.15.0/mockito-core-2.15.0.jar:/.m2/net/bytebuddy/byte-buddy/1.7.11/byte-buddy-1.7.11.jar:/.m2/net/bytebuddy/byte-buddy-agent/1.7.11/byte-buddy-agent-1.7.11.jar:/.m2/org/objenesis/objenesis/2.6/objenesis-2.6.jar:/.m2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/.m2/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar:/.m2/org/skyscreamer/jsonassert/1.5.0/jsonassert-1.5.0.jar:/.m2/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar:/.m2/org/springframework/spring-core/5.0.5.RELEASE/spring-core-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-jcl/5.0.5.RELEASE/spring-jcl-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-test/5.0.5.RELEASE/spring-test-5.0.5.RELEASE.jar:/.m2/org/xmlunit/xmlunit-core/2.5.1/xmlunit-core-2.5.1.jar:/.m2/com/jayway/jsonpath/json-path/2.4.0/json-path-2.4.0.jar:/.m2/net/minidev/json-smart/2.3/json-smart-2.3.jar:/.m2/net/minidev/accessors-smart/1.2/accessors-smart-1.2.jar:/.m2/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar:/.m2/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:, user.name=root, java.vm.specification.version=1.8, sun.java.command=/builds/root/spring-demo/target/surefire/surefirebooter5714235678873556567.jar /builds/root/spring-demo/target/surefire 2021-07-22T02-57-45_605-jvmRun1 surefire3374515824924664810tmp surefire_06513386400555942857tmp, java.home=/usr/local/openjdk-8/jre, sun.arch.data.model=64, user.language=en, java.specification.vendor=Oracle Corporation, awt.toolkit=sun.awt.X11.XToolkit, java.vm.info=mixed mode, java.version=1.8.0_302, java.ext.dirs=/usr/local/openjdk-8/jre/lib/ext:/usr/java/packages/lib/ext, sun.boot.class.path=/usr/local/openjdk-8/jre/lib/resources.jar:/usr/local/openjdk-8/jre/lib/rt.jar:/usr/local/openjdk-8/jre/lib/sunrsasign.jar:/usr/local/openjdk-8/jre/lib/jsse.jar:/usr/local/openjdk-8/jre/lib/jce.jar:/usr/local/openjdk-8/jre/lib/charsets.jar:/usr/local/openjdk-8/jre/lib/jfr.jar:/usr/local/openjdk-8/jre/classes, java.vendor=Oracle Corporation, localRepository=/.m2, file.separator=/, java.vendor.url.bug=http://bugreport.sun.com/bugreport/, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.cpu.isalist=}}, SystemEnvironmentPropertySource@1075738627 {
    name='systemEnvironment', properties={
    CI_COMMIT_MESSAGE=修改配置
, PATH=/usr/local/openjdk-8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin, CI_SERVER_VERSION_MAJOR=14, CI_PROJECT_URL=http://192.168.0.87:8880/root/spring-demo, CI_COMMIT_REF_SLUG=master, GITLAB_FEATURES=, CI_PROJECT_PATH_SLUG=root-spring-demo, FF_USE_NEW_BASH_EVAL_STRATEGY=false, CI_SERVER_VERSION_MINOR=0, PWD=/builds/root/spring-demo, FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY=false, CI_SERVER=yes, SERVER_PORT=8075, CI_PROJECT_VISIBILITY=private, CI_BUILD_NAME=package, CI_PROJECT_TITLE=spring-demo, FF_USE_WINDOWS_LEGACY_PROCESS_STRATEGY=true, CI_PIPELINE_SOURCE=push, CI_RUNNER_ID=5, CI_REGISTRY_USER=gitlab-ci-token, CI_COMMIT_REF_NAME=master, CI_NODE_TOTAL=1, CI_SERVER_URL=http://192.168.0.87:8880, CI_COMMIT_TIMESTAMP=2021-07-22T10:56:57+08:00, SHLVL=1, CI_BUILD_REF_NAME=master, CI_JOB_STATUS=running, CI_PROJECT_REPOSITORY_LANGUAGES=java,dockerfile, CI_PAGES_URL=http://root.example.com/spring-demo, JAVA_HOME=/usr/local/openjdk-8, CI_JOB_STAGE=package, IMAGE_VERSION=0.0.1-SNAPSHOT, CI_PAGES_DOMAIN=example.com, CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX=192.168.0.87:8880/root/dependency_proxy/containers, CI_BUILD_STAGE=package, CI_CONCURRENT_ID=0, CI_RUNNER_REVISION=c1edb478, CI_PIPELINE_ID=68, CI_PROJECT_NAMESPACE=root, CI_JOB_JWT=[MASKED], CI_JOB_IMAGE=maven:3-jdk-8, JAVA_VERSION=8u302, CI_BUILD_TOKEN=[MASKED], FF_CMD_DISABLE_DELAYED_ERROR_LEVEL_EXPANSION=false, CI_RUNNER_EXECUTABLE_ARCH=linux/amd64, _=/usr/bin/mvn, CI_PROJECT_NAME=spring-demo, CI_BUILD_REF_SLUG=master, CI=true, FF_SKIP_NOOP_BUILD_STAGES=true, FF_NETWORK_PER_BUILD=false, CI_JOB_TOKEN=[MASKED], MAVEN_PROJECTBASEDIR=/builds/root/spring-demo, CI_PROJECT_DIR=/builds/root/spring-demo, CI_RUNNER_VERSION=14.0.1, TAG=192.168.0.86:8075/spring-demo:0.0.1-SNAPSHOT, CI_COMMIT_SHA=12937c30983a27ed9f5ff5839c6eb8544b6fc8b2, FF_GITLAB_REGISTRY_HELPER_IMAGE=true, CI_SERVER_REVISION=25fc1060aff, CI_JOB_STARTED_AT=2021-07-22T10:57:14+08:00, CI_CONCURRENT_PROJECT_ID=0, MAVEN_HOME=/usr/share/maven, CI_DEPENDENCY_PROXY_USER=gitlab-ci-token, CI_PIPELINE_URL=http://192.168.0.87:8880/root/spring-demo/-/pipelines/68, CI_SERVER_PORT=8880, CI_COMMIT_BEFORE_SHA=865cef8e59757322b9cb1050b2a8450644ffded4, DOCKER_DRIVER=overlay2, CI_SERVER_NAME=GitLab, CI_COMMIT_SHORT_SHA=12937c30, CI_JOB_URL=http://192.168.0.87:8880/root/spring-demo/-/jobs/153, FF_USE_POWERSHELL_PATH_RESOLVER=false, GITLAB_USER_NAME=Administrator, CI_BUILDS_DIR=/builds, IMAGE_NAME=spring-demo, CI_RUNNER_TAGS=mvn-package, CI_SERVER_VERSION_PATCH=5, OLDPWD=/builds/root/spring-demo, CI_SERVER_PROTOCOL=http, CI_COMMIT_BRANCH=master, FF_ENABLE_BASH_EXIT_CODE_CHECK=false, GITLAB_CI=true, REGISTRY_URL=http://192.168.0.86:8075, CI_JOB_ID=153, GITLAB_USER_ID=1, CI_PIPELINE_IID=68, CI_SERVER_VERSION=14.0.5, CI_COMMIT_TITLE=修改配置, REGISTRY_USER=admin, CI_DEPENDENCY_PROXY_SERVER=192.168.0.87:8880, DOCKER_HOST=tcp://192.168.0.86:2375, CI_API_V4_URL=http://192.168.0.87:8880/api/v4, GITLAB_USER_EMAIL=admin@example.com, CI_PROJECT_ROOT_NAMESPACE=root, CI_BUILD_REF=12937c30983a27ed9f5ff5839c6eb8544b6fc8b2, CI_PROJECT_ID=2, CI_RUNNER_DESCRIPTION=package-runner, LANG=C.UTF-8, CI_REGISTRY_PASSWORD=[MASKED], CI_PROJECT_PATH=root/spring-demo, CI_COMMIT_REF_PROTECTED=true, MAVEN_OPTS= -Dmaven.repo.local=/.m2, CI_DEFAULT_BRANCH=master, CI_DISPOSABLE_ENVIRONMENT=true, CI_RUNNER_SHORT_TOKEN=7tH14pxU, CI_COMMIT_AUTHOR=test <test@qq.com>, FF_SKIP_DOCKER_MACHINE_PROVISION_ON_CREATION_FAILURE=false, CI_CONFIG_PATH=.gitlab-ci.yml, CI_BUILD_BEFORE_SHA=865cef8e59757322b9cb1050b2a8450644ffded4, MAVEN_CMD_LINE_ARGS= clean package docker:build, CI_COMMIT_DESCRIPTION=, REGISTRY_PWD=admin123, CI_DEPENDENCY_PROXY_PASSWORD=[MASKED], CI_SERVER_HOST=192.168.0.87, CI_PIPELINE_CREATED_AT=2021-07-22T10:57:05+08:00, FF_DISABLE_UMASK_FOR_DOCKER_EXECUTOR=false, SERVER_IP=192.168.0.86, FF_USE_FASTZIP=false, FF_USE_DIRECT_DOWNLOAD=true, HOSTNAME=runner-7th14pxu-project-2-concurrent-0, CI_BUILD_ID=153, CI_JOB_NAME=package, GITLAB_USER_LOGIN=root, CI_REPOSITORY_URL=http://gitlab-ci-token:[MASKED]@192.168.0.87:8880/root/spring-demo.git, HOME=/root}}]
02:57:47.222 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved classpath location [com/example/demo/] to resources [URL [file:/builds/root/spring-demo/target/test-classes/com/example/demo/], URL [file:/builds/root/spring-demo/target/classes/com/example/demo/]]
02:57:47.222 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in directory tree [/builds/root/spring-demo/target/test-classes/com/example/demo]
02:57:47.222 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [/builds/root/spring-demo/target/test-classes/com/example/demo] for files matching pattern [/builds/root/spring-demo/target/test-classes/com/example/demo/*.class]
02:57:47.246 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in directory tree [/builds/root/spring-demo/target/classes/com/example/demo]
02:57:47.247 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [/builds/root/spring-demo/target/classes/com/example/demo] for files matching pattern [/builds/root/spring-demo/target/classes/com/example/demo/*.class]
02:57:47.247 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved location pattern [classpath*:com/example/demo/*.class] to resources [file [/builds/root/spring-demo/target/test-classes/com/example/demo/DemoApplicationTests.class], file [/builds/root/spring-demo/target/classes/com/example/demo/DemoApplication.class]]
02:57:47.370 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/builds/root/spring-demo/target/classes/com/example/demo/DemoApplication.class]
02:57:47.372 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.example.demo.DemoApplication for test class com.example.demo.DemoApplicationTests
02:57:47.551 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.example.demo.DemoApplicationTests]: using defaults.
02:57:47.551 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
02:57:47.584 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/TransactionDefinition]
02:57:47.589 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
02:57:47.589 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@35e2d654, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@1bd4fdd, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@55183b20, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@4f83df68, org.springframework.test.context.support.DirtiesContextTestExecutionListener@6cf0e0ba, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@7d8995e, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@130d63be, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@42a48628, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@293a5bf6, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@6aeb35e6]
02:57:47.590 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.DemoApplicationTests]
02:57:47.591 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.DemoApplicationTests]
02:57:47.598 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.DemoApplicationTests]
02:57:47.598 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.DemoApplicationTests]
02:57:47.598 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.DemoApplicationTests]
02:57:47.598 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.DemoApplicationTests]
02:57:47.604 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@692f203f testClass = DemoApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@48f2bd5b testClass = DemoApplicationTests, locations = '{}', classes = '{class com.example.demo.DemoApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@436e852b, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@3e57cd70, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@7b69c6ba, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@1b26f7b2], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> false]], class annotated with @DirtiesContext [false] with mode [null].
02:57:47.604 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.DemoApplicationTests]
02:57:47.604 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.DemoApplicationTests]
02:57:47.619 [main] DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext@692f203f testClass = DemoApplicationTests, testInstance = com.example.demo.DemoApplicationTests@515c6049, testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@48f2bd5b testClass = DemoApplicationTests, locations = '{}', classes = '{class com.example.demo.DemoApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@436e852b, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@3e57cd70, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@7b69c6ba, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@1b26f7b2], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> false]]].
02:57:47.659 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding PropertySource 'systemProperties' with lowest search precedence
02:57:47.659 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding PropertySource 'systemEnvironment' with lowest search precedence
02:57:47.659 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [MapPropertySource@1658699134 {
    name='systemProperties', properties={
    java.runtime.name=OpenJDK Runtime Environment, sun.boot.library.path=/usr/local/openjdk-8/jre/lib/amd64, java.vm.version=25.302-b08, java.vm.vendor=Oracle Corporation, java.vendor.url=http://java.oracle.com/, path.separator=:, java.vm.name=OpenJDK 64-Bit Server VM, file.encoding.pkg=sun.io, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/builds/root/spring-demo, java.runtime.version=1.8.0_302-b08, basedir=/builds/root/spring-demo, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.endorsed.dirs=/usr/local/openjdk-8/jre/lib/endorsed, os.arch=amd64, surefire.real.class.path=/builds/root/spring-demo/target/surefire/surefirebooter5714235678873556567.jar, java.io.tmpdir=/tmp, line.separator=
, java.vm.specification.vendor=Oracle Corporation, os.name=Linux, sun.jnu.encoding=UTF-8, java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib, surefire.test.class.path=/builds/root/spring-demo/target/test-classes:/builds/root/spring-demo/target/classes:/.m2/org/springframework/boot/spring-boot-starter-web/2.0.1.RELEASE/spring-boot-starter-web-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter/2.0.1.RELEASE/spring-boot-starter-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot/2.0.1.RELEASE/spring-boot-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-autoconfigure/2.0.1.RELEASE/spring-boot-autoconfigure-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter-logging/2.0.1.RELEASE/spring-boot-starter-logging-2.0.1.RELEASE.jar:/.m2/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/.m2/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/.m2/org/apache/logging/log4j/log4j-to-slf4j/2.10.0/log4j-to-slf4j-2.10.0.jar:/.m2/org/apache/logging/log4j/log4j-api/2.10.0/log4j-api-2.10.0.jar:/.m2/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar:/.m2/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/.m2/org/yaml/snakeyaml/1.19/snakeyaml-1.19.jar:/.m2/org/springframework/boot/spring-boot-starter-json/2.0.1.RELEASE/spring-boot-starter-json-2.0.1.RELEASE.jar:/.m2/com/fasterxml/jackson/core/jackson-databind/2.9.5/jackson-databind-2.9.5.jar:/.m2/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/.m2/com/fasterxml/jackson/core/jackson-core/2.9.5/jackson-core-2.9.5.jar:/.m2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.5/jackson-datatype-jdk8-2.9.5.jar:/.m2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.5/jackson-datatype-jsr310-2.9.5.jar:/.m2/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.5/jackson-module-parameter-names-2.9.5.jar:/.m2/org/springframework/boot/spring-boot-starter-tomcat/2.0.1.RELEASE/spring-boot-starter-tomcat-2.0.1.RELEASE.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-core/8.5.29/tomcat-embed-core-8.5.29.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-el/8.5.29/tomcat-embed-el-8.5.29.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.29/tomcat-embed-websocket-8.5.29.jar:/.m2/org/hibernate/validator/hibernate-validator/6.0.9.Final/hibernate-validator-6.0.9.Final.jar:/.m2/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/.m2/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/.m2/com/fasterxml/classmate/1.3.4/classmate-1.3.4.jar:/.m2/org/springframework/spring-web/5.0.5.RELEASE/spring-web-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-beans/5.0.5.RELEASE/spring-beans-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-webmvc/5.0.5.RELEASE/spring-webmvc-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-aop/5.0.5.RELEASE/spring-aop-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-context/5.0.5.RELEASE/spring-context-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-expression/5.0.5.RELEASE/spring-expression-5.0.5.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter-test/2.0.1.RELEASE/spring-boot-starter-test-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-test/2.0.1.RELEASE/spring-boot-test-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-test-autoconfigure/2.0.1.RELEASE/spring-boot-test-autoconfigure-2.0.1.RELEASE.jar:/.m2/junit/junit/4.12/junit-4.12.jar:/.m2/org/assertj/assertj-core/3.9.1/assertj-core-3.9.1.jar:/.m2/org/mockito/mockito-core/2.15.0/mockito-core-2.15.0.jar:/.m2/net/bytebuddy/byte-buddy/1.7.11/byte-buddy-1.7.11.jar:/.m2/net/bytebuddy/byte-buddy-agent/1.7.11/byte-buddy-agent-1.7.11.jar:/.m2/org/objenesis/objenesis/2.6/objenesis-2.6.jar:/.m2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/.m2/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar:/.m2/org/skyscreamer/jsonassert/1.5.0/jsonassert-1.5.0.jar:/.m2/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar:/.m2/org/springframework/spring-core/5.0.5.RELEASE/spring-core-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-jcl/5.0.5.RELEASE/spring-jcl-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-test/5.0.5.RELEASE/spring-test-5.0.5.RELEASE.jar:/.m2/org/xmlunit/xmlunit-core/2.5.1/xmlunit-core-2.5.1.jar:/.m2/com/jayway/jsonpath/json-path/2.4.0/json-path-2.4.0.jar:/.m2/net/minidev/json-smart/2.3/json-smart-2.3.jar:/.m2/net/minidev/accessors-smart/1.2/accessors-smart-1.2.jar:/.m2/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar:/.m2/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:, java.specification.name=Java Platform API Specification, java.class.version=52.0, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, os.version=3.10.0-1160.el7.x86_64, user.home=/root, user.timezone=Etc/UTC, java.awt.printerjob=sun.print.PSPrinterJob, file.encoding=UTF-8, java.specification.version=1.8, java.class.path=/builds/root/spring-demo/target/test-classes:/builds/root/spring-demo/target/classes:/.m2/org/springframework/boot/spring-boot-starter-web/2.0.1.RELEASE/spring-boot-starter-web-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter/2.0.1.RELEASE/spring-boot-starter-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot/2.0.1.RELEASE/spring-boot-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-autoconfigure/2.0.1.RELEASE/spring-boot-autoconfigure-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter-logging/2.0.1.RELEASE/spring-boot-starter-logging-2.0.1.RELEASE.jar:/.m2/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/.m2/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/.m2/org/apache/logging/log4j/log4j-to-slf4j/2.10.0/log4j-to-slf4j-2.10.0.jar:/.m2/org/apache/logging/log4j/log4j-api/2.10.0/log4j-api-2.10.0.jar:/.m2/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar:/.m2/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/.m2/org/yaml/snakeyaml/1.19/snakeyaml-1.19.jar:/.m2/org/springframework/boot/spring-boot-starter-json/2.0.1.RELEASE/spring-boot-starter-json-2.0.1.RELEASE.jar:/.m2/com/fasterxml/jackson/core/jackson-databind/2.9.5/jackson-databind-2.9.5.jar:/.m2/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/.m2/com/fasterxml/jackson/core/jackson-core/2.9.5/jackson-core-2.9.5.jar:/.m2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.5/jackson-datatype-jdk8-2.9.5.jar:/.m2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.5/jackson-datatype-jsr310-2.9.5.jar:/.m2/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.5/jackson-module-parameter-names-2.9.5.jar:/.m2/org/springframework/boot/spring-boot-starter-tomcat/2.0.1.RELEASE/spring-boot-starter-tomcat-2.0.1.RELEASE.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-core/8.5.29/tomcat-embed-core-8.5.29.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-el/8.5.29/tomcat-embed-el-8.5.29.jar:/.m2/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.29/tomcat-embed-websocket-8.5.29.jar:/.m2/org/hibernate/validator/hibernate-validator/6.0.9.Final/hibernate-validator-6.0.9.Final.jar:/.m2/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/.m2/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/.m2/com/fasterxml/classmate/1.3.4/classmate-1.3.4.jar:/.m2/org/springframework/spring-web/5.0.5.RELEASE/spring-web-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-beans/5.0.5.RELEASE/spring-beans-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-webmvc/5.0.5.RELEASE/spring-webmvc-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-aop/5.0.5.RELEASE/spring-aop-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-context/5.0.5.RELEASE/spring-context-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-expression/5.0.5.RELEASE/spring-expression-5.0.5.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-starter-test/2.0.1.RELEASE/spring-boot-starter-test-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-test/2.0.1.RELEASE/spring-boot-test-2.0.1.RELEASE.jar:/.m2/org/springframework/boot/spring-boot-test-autoconfigure/2.0.1.RELEASE/spring-boot-test-autoconfigure-2.0.1.RELEASE.jar:/.m2/junit/junit/4.12/junit-4.12.jar:/.m2/org/assertj/assertj-core/3.9.1/assertj-core-3.9.1.jar:/.m2/org/mockito/mockito-core/2.15.0/mockito-core-2.15.0.jar:/.m2/net/bytebuddy/byte-buddy/1.7.11/byte-buddy-1.7.11.jar:/.m2/net/bytebuddy/byte-buddy-agent/1.7.11/byte-buddy-agent-1.7.11.jar:/.m2/org/objenesis/objenesis/2.6/objenesis-2.6.jar:/.m2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/.m2/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar:/.m2/org/skyscreamer/jsonassert/1.5.0/jsonassert-1.5.0.jar:/.m2/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar:/.m2/org/springframework/spring-core/5.0.5.RELEASE/spring-core-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-jcl/5.0.5.RELEASE/spring-jcl-5.0.5.RELEASE.jar:/.m2/org/springframework/spring-test/5.0.5.RELEASE/spring-test-5.0.5.RELEASE.jar:/.m2/org/xmlunit/xmlunit-core/2.5.1/xmlunit-core-2.5.1.jar:/.m2/com/jayway/jsonpath/json-path/2.4.0/json-path-2.4.0.jar:/.m2/net/minidev/json-smart/2.3/json-smart-2.3.jar:/.m2/net/minidev/accessors-smart/1.2/accessors-smart-1.2.jar:/.m2/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar:/.m2/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:, user.name=root, java.vm.specification.version=1.8, sun.java.command=/builds/root/spring-demo/target/surefire/surefirebooter5714235678873556567.jar /builds/root/spring-demo/target/surefire 2021-07-22T02-57-45_605-jvmRun1 surefire3374515824924664810tmp surefire_06513386400555942857tmp, java.home=/usr/local/openjdk-8/jre, sun.arch.data.model=64, user.language=en, java.specification.vendor=Oracle Corporation, awt.toolkit=sun.awt.X11.XToolkit, java.vm.info=mixed mode, java.version=1.8.0_302, java.ext.dirs=/usr/local/openjdk-8/jre/lib/ext:/usr/java/packages/lib/ext, sun.boot.class.path=/usr/local/openjdk-8/jre/lib/resources.jar:/usr/local/openjdk-8/jre/lib/rt.jar:/usr/local/openjdk-8/jre/lib/sunrsasign.jar:/usr/local/openjdk-8/jre/lib/jsse.jar:/usr/local/openjdk-8/jre/lib/jce.jar:/usr/local/openjdk-8/jre/lib/charsets.jar:/usr/local/openjdk-8/jre/lib/jfr.jar:/usr/local/openjdk-8/jre/classes, java.vendor=Oracle Corporation, localRepository=/.m2, file.separator=/, java.vendor.url.bug=http://bugreport.sun.com/bugreport/, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.cpu.isalist=}}, SystemEnvironmentPropertySource@1961176822 {
    name='systemEnvironment', properties={
    CI_COMMIT_MESSAGE=修改配置
, PATH=/usr/local/openjdk-8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin, CI_SERVER_VERSION_MAJOR=14, CI_PROJECT_URL=http://192.168.0.87:8880/root/spring-demo, CI_COMMIT_REF_SLUG=master, GITLAB_FEATURES=, CI_PROJECT_PATH_SLUG=root-spring-demo, FF_USE_NEW_BASH_EVAL_STRATEGY=false, CI_SERVER_VERSION_MINOR=0, PWD=/builds/root/spring-demo, FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY=false, CI_SERVER=yes, SERVER_PORT=8075, CI_PROJECT_VISIBILITY=private, CI_BUILD_NAME=package, CI_PROJECT_TITLE=spring-demo, FF_USE_WINDOWS_LEGACY_PROCESS_STRATEGY=true, CI_PIPELINE_SOURCE=push, CI_RUNNER_ID=5, CI_REGISTRY_USER=gitlab-ci-token, CI_COMMIT_REF_NAME=master, CI_NODE_TOTAL=1, CI_SERVER_URL=http://192.168.0.87:8880, CI_COMMIT_TIMESTAMP=2021-07-22T10:56:57+08:00, SHLVL=1, CI_BUILD_REF_NAME=master, CI_JOB_STATUS=running, CI_PROJECT_REPOSITORY_LANGUAGES=java,dockerfile, CI_PAGES_URL=http://root.example.com/spring-demo, JAVA_HOME=/usr/local/openjdk-8, CI_JOB_STAGE=package, IMAGE_VERSION=0.0.1-SNAPSHOT, CI_PAGES_DOMAIN=example.com, CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX=192.168.0.87:8880/root/dependency_proxy/containers, CI_BUILD_STAGE=package, CI_CONCURRENT_ID=0, CI_RUNNER_REVISION=c1edb478, CI_PIPELINE_ID=68, CI_PROJECT_NAMESPACE=root, CI_JOB_JWT=[MASKED], CI_JOB_IMAGE=maven:3-jdk-8, JAVA_VERSION=8u302, CI_BUILD_TOKEN=[MASKED], FF_CMD_DISABLE_DELAYED_ERROR_LEVEL_EXPANSION=false, CI_RUNNER_EXECUTABLE_ARCH=linux/amd64, _=/usr/bin/mvn, CI_PROJECT_NAME=spring-demo, CI_BUILD_REF_SLUG=master, CI=true, FF_SKIP_NOOP_BUILD_STAGES=true, FF_NETWORK_PER_BUILD=false, CI_JOB_TOKEN=[MASKED], MAVEN_PROJECTBASEDIR=/builds/root/spring-demo, CI_PROJECT_DIR=/builds/root/spring-demo, CI_RUNNER_VERSION=14.0.1, TAG=192.168.0.86:8075/spring-demo:0.0.1-SNAPSHOT, CI_COMMIT_SHA=12937c30983a27ed9f5ff5839c6eb8544b6fc8b2, FF_GITLAB_REGISTRY_HELPER_IMAGE=true, CI_SERVER_REVISION=25fc1060aff, CI_JOB_STARTED_AT=2021-07-22T10:57:14+08:00, CI_CONCURRENT_PROJECT_ID=0, MAVEN_HOME=/usr/share/maven, CI_DEPENDENCY_PROXY_USER=gitlab-ci-token, CI_PIPELINE_URL=http://192.168.0.87:8880/root/spring-demo/-/pipelines/68, CI_SERVER_PORT=8880, CI_COMMIT_BEFORE_SHA=865cef8e59757322b9cb1050b2a8450644ffded4, DOCKER_DRIVER=overlay2, CI_SERVER_NAME=GitLab, CI_COMMIT_SHORT_SHA=12937c30, CI_JOB_URL=http://192.168.0.87:8880/root/spring-demo/-/jobs/153, FF_USE_POWERSHELL_PATH_RESOLVER=false, GITLAB_USER_NAME=Administrator, CI_BUILDS_DIR=/builds, IMAGE_NAME=spring-demo, CI_RUNNER_TAGS=mvn-package, CI_SERVER_VERSION_PATCH=5, OLDPWD=/builds/root/spring-demo, CI_SERVER_PROTOCOL=http, CI_COMMIT_BRANCH=master, FF_ENABLE_BASH_EXIT_CODE_CHECK=false, GITLAB_CI=true, REGISTRY_URL=http://192.168.0.86:8075, CI_JOB_ID=153, GITLAB_USER_ID=1, CI_PIPELINE_IID=68, CI_SERVER_VERSION=14.0.5, CI_COMMIT_TITLE=修改配置, REGISTRY_USER=admin, CI_DEPENDENCY_PROXY_SERVER=192.168.0.87:8880, DOCKER_HOST=tcp://192.168.0.86:2375, CI_API_V4_URL=http://192.168.0.87:8880/api/v4, GITLAB_USER_EMAIL=admin@example.com, CI_PROJECT_ROOT_NAMESPACE=root, CI_BUILD_REF=12937c30983a27ed9f5ff5839c6eb8544b6fc8b2, CI_PROJECT_ID=2, CI_RUNNER_DESCRIPTION=package-runner, LANG=C.UTF-8, CI_REGISTRY_PASSWORD=[MASKED], CI_PROJECT_PATH=root/spring-demo, CI_COMMIT_REF_PROTECTED=true, MAVEN_OPTS= -Dmaven.repo.local=/.m2, CI_DEFAULT_BRANCH=master, CI_DISPOSABLE_ENVIRONMENT=true, CI_RUNNER_SHORT_TOKEN=7tH14pxU, CI_COMMIT_AUTHOR=test <test@qq.com>, FF_SKIP_DOCKER_MACHINE_PROVISION_ON_CREATION_FAILURE=false, CI_CONFIG_PATH=.gitlab-ci.yml, CI_BUILD_BEFORE_SHA=865cef8e59757322b9cb1050b2a8450644ffded4, MAVEN_CMD_LINE_ARGS= clean package docker:build, CI_COMMIT_DESCRIPTION=, REGISTRY_PWD=admin123, CI_DEPENDENCY_PROXY_PASSWORD=[MASKED], CI_SERVER_HOST=192.168.0.87, CI_PIPELINE_CREATED_AT=2021-07-22T10:57:05+08:00, FF_DISABLE_UMASK_FOR_DOCKER_EXECUTOR=false, SERVER_IP=192.168.0.86, FF_USE_FASTZIP=false, FF_USE_DIRECT_DOWNLOAD=true, HOSTNAME=runner-7th14pxu-project-2-concurrent-0, CI_BUILD_ID=153, CI_JOB_NAME=package, GITLAB_USER_LOGIN=root, CI_REPOSITORY_URL=http://gitlab-ci-token:[MASKED]@192.168.0.87:8880/root/spring-demo.git, HOME=/root}}]
02:57:47.660 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {
    spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}
02:57:47.660 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding PropertySource 'Inlined Test Properties' with highest search precedence.   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )' |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot :: (v2.0.1.RELEASE) 2021-07-22 02:57:48.376 INFO 79 --- [ main] com.example.demo.DemoApplicationTests : Starting DemoApplicationTests on runner-7th14pxu-project-2-concurrent-0 with PID 79 (started by root in /builds/root/spring-demo) 2021-07-22 02:57:48.377 INFO 79 --- [ main] com.example.demo.DemoApplicationTests : No active profile set, falling back to default profiles: default 2021-07-22 02:57:48.443 INFO 79 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2af004b: startup date [Thu Jul 22 02:57:48 UTC 2021]; root of context hierarchy 2021-07-22 02:57:50.684 INFO 79 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 0 (http) 2021-07-22 02:57:50.744 INFO 79 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2021-07-22 02:57:50.745 INFO 79 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.29 2021-07-22 02:57:50.788 INFO 79 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib] 2021-07-22 02:57:50.939 INFO 79 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/demo] : Initializing Spring embedded WebApplicationContext 2021-07-22 02:57:50.939 INFO 79 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2498 ms 2021-07-22 02:57:51.137 INFO 79 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/] 2021-07-22 02:57:51.140 INFO 79 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2021-07-22 02:57:51.140 INFO 79 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2021-07-22 02:57:51.140 INFO 79 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2021-07-22 02:57:51.140 INFO 79 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2021-07-22 02:57:51.396 INFO 79 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2021-07-22 02:57:51.726 INFO 79 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2af004b: startup date [Thu Jul 22 02:57:48 UTC 2021]; root of context hierarchy 2021-07-22 02:57:51.842 INFO 79 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto java.lang.String com.example.demo.DemoApplication.home() 2021-07-22 02:57:51.844 INFO 79 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 2021-07-22 02:57:51.845 INFO 79 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 2021-07-22 02:57:51.882 INFO 79 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2021-07-22 02:57:51.900 INFO 79 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2021-07-22 02:57:52.225 INFO 79 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 34437 (http) with context path '/demo' 2021-07-22 02:57:52.237 INFO 79 --- [ main] com.example.demo.DemoApplicationTests : Started DemoApplicationTests in 4.573 seconds (JVM running for 6.146) 2021-07-22 02:57:52.466 INFO 79 --- [o-auto-1-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/demo] : Initializing Spring FrameworkServlet 'dispatcherServlet' 2021-07-22 02:57:52.466 INFO 79 --- [o-auto-1-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started 2021-07-22 02:57:52.493 INFO 79 --- [o-auto-1-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 27 ms [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.231 s - in com.example.demo.DemoApplicationTests 2021-07-22 02:57:52.767 INFO 79 --- [ Thread-3] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2af004b: startup date [Thu Jul 22 02:57:48 UTC 2021]; root of context hierarchy [INFO] [INFO] Results: [INFO] [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ spring-demo --- [INFO] Building jar: /builds/root/spring-demo/target/spring-demo-0.0.1-SNAPSHOT.jar [INFO] [INFO] --- spring-boot-maven-plugin:2.0.1.RELEASE:repackage (default) @ spring-demo --- [INFO] [INFO] --- docker-maven-plugin:1.2.2:build (default-cli) @ spring-demo --- [INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier] [INFO] Copying /builds/root/spring-demo/target/spring-demo-0.0.1-SNAPSHOT.jar -> /builds/root/spring-demo/target/docker/spring-demo-0.0.1-SNAPSHOT.jar [INFO] Copying src/main/docker/Dockerfile -> /builds/root/spring-demo/target/docker/Dockerfile [INFO] Building image 192.168.0.86:8075/spring-demo:0.0.1-SNAPSHOT Step 1/9 : FROM java:8---> d23bdf5b1b1b Step 2/9 : MAINTAINER wangsh---> Using cache---> d9beb5070a95 Step 3/9 : VOLUME /tmp---> Using cache---> 47de9369f756 Step 4/9 : ADD *.jar spring-demo.jar---> a2eefec044bb Step 5/9 : RUN sh -c 'touch /spring-demo.jar'---> Running in ccbd3047ebb4
Removing intermediate container ccbd3047ebb4---> 335fa2b586ab
Step 6/9 : EXPOSE 9080---> Running in 6a08c8489cd8
Removing intermediate container 6a08c8489cd8---> 3f7bd59924bc
Step 7/9 : ENV JAVA_OPTS="-Xmx2048m -Xms2048m"---> Running in 8e7909f498f6
Removing intermediate container 8e7909f498f6---> 6a52285b7966
Step 8/9 : ENV SERVER_PORT="--server.port=9085"---> Running in c33405aedfa1
Removing intermediate container c33405aedfa1---> d67a7b82c712
Step 9/9 : ENTRYPOINT java -server ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /spring-demo.jar ${SERVER_PORT}---> Running in f05f80a57efd
Removing intermediate container f05f80a57efd---> ad88808811a2
ProgressMessage{
    id=null, status=null, stream=null, error=null, progress=null, progressDetail=null}
Successfully built ad88808811a2
Successfully tagged 192.168.0.86:8075/spring-demo:0.0.1-SNAPSHOT
[INFO] Built 192.168.0.86:8075/spring-demo:0.0.1-SNAPSHOT
[INFO] Tagging 192.168.0.86:8075/spring-demo:0.0.1-SNAPSHOT with 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  21.924 s
[INFO] Finished at: 2021-07-22T02:58:04Z
[INFO] ------------------------------------------------------------------------
Saving cache for successful job
00:01
Creating cache default-1...
WARNING: .m2/repository: no matching files         
Archive is up to date!                             
Created cache
Uploading artifacts for successful job
00:01
Uploading artifacts...
target/*.jar: found 1 matching files and directories 
Uploading artifacts as "archive" to coordinator... ok  id=153 responseStatus=201 Created token=j42qj8s1
Job succeeded

以上执行maven打包,首次执行下载jar包较慢,需要等待一段时间,由于我们这里设置了缓存目录,下载执行是首先查看本地,如果本地已经存在,则不下载。
查看宿主机maven下载jar包仓库:
在这里插入图片描述
可以看到已经下载jar包到本地机器。
Job2执行deploy结果:
在这里插入图片描述
详细信息:

Running with gitlab-runner 14.0.1 (c1edb478)on deploy-runner ecsZZi3q
Preparing the "docker" executor
Using Docker executor with image docker:latest ...
Pulling docker image docker:latest ...
Using docker image sha256:08bdaf2f88f90320cd3e92a469969efb1f066c6d318631f94e7864828abd7c75 for docker:latest with digest docker@sha256:a61102937d2bda8319882998ef1ffa27387617f6eea6c298b18a05f7fba82c0d ...
Preparing environment
00:01
Running on runner-ecszzi3q-project-2-concurrent-0 via 647ad32b7320...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/root/spring-demo/.git/
Checking out 12937c30 as master...
Removing target/
Skipping Git submodules setup
Restoring cache
00:00
Checking cache for default-1...
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted. 
Successfully extracted cache
Downloading artifacts
Downloading artifacts for package (153)...
Downloading artifacts from coordinator... ok        id=153 responseStatus=200 OK token=j42qj8s1
Executing "step_script" stage of the job script
Using docker image sha256:08bdaf2f88f90320cd3e92a469969efb1f066c6d318631f94e7864828abd7c75 for docker:latest with digest docker@sha256:a61102937d2bda8319882998ef1ffa27387617f6eea6c298b18a05f7fba82c0d ...
$ echo "=============== deploy ==============="
=============== deploy  ===============
$ docker login --username $REGISTRY_USER --password $REGISTRY_PWD $REGISTRY_URL
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
$ docker push $TAG
The push refers to repository [192.168.0.86:8075/spring-demo]
6cc3073c0661: Preparing
bf3383134655: Preparing
35c20f26d188: Preparing
c3fe59dd9556: Preparing
6ed1a81ba5b6: Preparing
a3483ce177ce: Preparing
ce6c8756685b: Preparing
30339f20ced0: Preparing
0eb22bfb707d: Preparing
a2ae92ffcd29: Preparing
a3483ce177ce: Waiting
ce6c8756685b: Waiting
30339f20ced0: Waiting
0eb22bfb707d: Waiting
a2ae92ffcd29: Waiting
6ed1a81ba5b6: Layer already exists
35c20f26d188: Layer already exists
c3fe59dd9556: Layer already exists
a3483ce177ce: Layer already exists
30339f20ced0: Layer already exists
ce6c8756685b: Layer already exists
a2ae92ffcd29: Layer already exists
0eb22bfb707d: Layer already exists
6cc3073c0661: Pushed
bf3383134655: Pushed
0.0.1-SNAPSHOT: digest: sha256:b764cfae505c25071806539708870fc0efcad04d283755b38e233751d02aff06 size: 2424
$ if [ $(docker ps -aq --filter name=$IMAGE_NAME) ]; then docker rm -f $IMAGE_NAME ;fi
$ docker image prune
WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] Total reclaimed space: 0B
$ docker run -dit --name $IMAGE_NAME -p 9080:9080 --restart=always $TAG
95c2e00bac2ed86830f05ecd5e9a7de9a497f2ac40af96285eb67d2ef20012bd
Saving cache for successful job
00:01
Creating cache default-1...
WARNING: .m2/repository: no matching files         
Archive is up to date!                             
Created cache
Job succeeded

以上时.gitlab-ci.yml中定义的job2执行结果,即deploy执行的登录私服,上传镜像,启动容器等操作结果。

查看打包结果

CI/CD pipelines任务执行完成后,查看执行结果,可以看到打包前后对比,打包完成已经生成docker镜像,并启动服务
打包前镜像:
在这里插入图片描述

打包后spring-demo镜像:在这里插入图片描述
启动spring-demo镜像:
在这里插入图片描述
demo下载地址:https://gitee.com/starsky20/docker-gitlab-cicd.git

安装错误

ERROR: Failed to load config stat /etc/gitlab-runner/config.toml: no such file or directory builds=0

以上时启动gitlab-runner时,需要加载一个config.toml配置文件,在容器启动时通过宿主机挂载到容器的/etc/gitlab-runner/config目录,而挂载宿主机目录还没有config.toml配置文件,所以提示以上错误。
解决办法:
进入到gitlab-runner容器内存,执行注册即可,注册完成会自动生成config.toml文件

Using locally found image version due to “if-not-present” pull policy

gitlab-runner 14版本不支持该属性,删除即可。

Could not transfer artifact com.jayway.jsonpath:json-path:jar:2.4.0

[ERROR] Failed to execute goal on project spring-demo: Could not resolve dependencies for project com.example:spring-demo:jar:0.0.1-SNAPSHOT: Could not transfer artifact com.jayway.jsonpath:json-path:jar:2.4.0 from/to central (https://repo.maven.apache.org/maven2): GET request of: com/jayway/jsonpath/json-path/2.4.0/json-path-2.4.0.jar from central failed: Connection reset -> [Help 1]

maven打包时提示缺少该jar包,在项目pom.xml文件中引入即可。

<dependency><groupId>com.jayway.jsonpath</groupId><artifactId>json-path</artifactId><version>2.4.0</version></dependency>

ERROR: Runner http://192.168.0.87:8880/j7jVRMZfo5srqW1TWEgL is not healthy and will be disabled!

原因:config.toml配置中token之和项目中token值不一致导致,重新注册runner即可。

"Can’t close tar writer: io: read/write on closed pipe

$ docker build -t spring-demo:0.0.1-SNAPSHOT .
27time=“2021-07-20T08:15:22Z” level=error msg=“Can’t add file /builds/root/spring-demo/.git/objects/9c/c84ea9b4d95453115d0c26488d6a78694e0bc6 to tar: io: read/write on closed pipe”
28time=“2021-07-20T08:15:22Z” level=error msg=“Can’t close tar writer: io: read/write on closed pipe”
29Error response from daemon: Client sent an HTTP request to an HTTPS server.
30ERROR: Job failed: exit code 1
面临的问题是因为生成pickle 对象的进程分配了不同的用户,然后访问pickle 对象的进程。
在 Dockerfile 中添加了如下步骤,RUN chown -R /home/data/gitlab/
把这个目录的权限打开:
chmod -R 777 /var/run/docker.sock

unable to find valid certification path to requested target

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (default-cli) on project spring-demo: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]

docker中增加了tls认证,客户端在执行docker命令时需要tls认证相关信息,将docker认证的ca.pem, cert.pem, key.pem文件放在指定位置,执行docker命令时加载认证文件信息即可。
例如:查看正在运行的容器
docker --tlsverify --tlscacert=/opt/cert/docker/ca.pem --tlscert=/opt/cert/docker/cert.pem --tlskey=/opt/cert/docker/key.pem -H tcp://47.119.120.197:2375 ps

on project spring-demo: Exception caught: no basic auth credentials

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (default-cli) on project spring-demo: Exception caught: no basic auth credentials -> [Help 1]
项目打包时提示授权问题,时由于docker登录私服时需要账号密码认证。
解决办法:
在docker配置文件/etc/docker/daemon.json中添加访问私服的地址:

 vim /etc/docker/daemon.json 
{
    "insecure-registries":["192.168.0.86:8076","192.168.0.86:8075"]
}
{
    "registry-mirrors": ["https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://hub-mirror.c.163.com","https://hub.docker.com","https://hub.daocloud.io"]
}

然后再docker执行login命令时添加上用户账号密码即可
docker login -u admin -p admin123 http://192.168.0.86:8075
在这里插入图片描述

Error response from daemon: Get http://192.168.0.87:8075/v2/: dial tcp 192.168.0.87:8075: connect: connection refused

26$ docker login --username admin --password admin123 192.168.0.87:8075
27WARNING! Using --password via the CLI is insecure. Use --password-stdin.
28Error response from daemon: Get http://192.168.0.87:8075/v2/: dial tcp 192.168.0.87:8075: connect: connection refused
29ERROR: Job failed: exit code 1

解决办法:
在docker配置文件/etc/docker/daemon.json中添加访问私服的地址:

 vim /etc/docker/daemon.json 
{
    "insecure-registries":["192.168.0.86:8076","192.168.0.86:8075"]
}
{
    "registry-mirrors": ["https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://hub-mirror.c.163.com","https://hub.docker.com","https://hub.daocloud.io"]
}
  相关解决方案