Jenkins是开源CI&CD软件领导者, 提供超过1000个插件来支持构建、部署、自动化, 满足任何项目的需要。
官网:https://www.jenkins.io/zh/
本篇博客介绍docker版的jenkins的安装和使用,maven、jdk,汉语的配置,期间遇到的各种问题及其解决方案,并给出一个简单的使用案例。
1.安装docker版本的jenkins;
2.配置jenkins,汉化,配置mvn,配置jdk;
3.拉取开源代码,进行maven的打包案例;
4.遇到的问题及其解决方案;
安装指引: https://www.jenkins.io/zh/doc/book/using/
vi /etc/docker/daemon.json
{
"registry-mirrors":
[
"https://docker.mirrors.ustc.edu.cn/",
"https://hub-mirror.c.163.com",
"https://ung2thfc.mirror.aliyuncs.com",
"https://registry.docker-cn.com"],
"live-restore": true,
"insecure-registries":["10.0.0.12:5000"]
}
systemctl restart docker
拉取成功
docker run \
-u root \
--name jenkins-blueocean \
-d \
-p 8080:8080 \
-p 50000:50000 \
-v /usr/local/software/jenkins:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
docker.io/jenkinsci/blueocean
查看日志,找到密码
自动安装一些插件
创建一个用户,后续登录用这个用户名和密码
选择插件进行安装
进行语言的设置
采用的是复制压缩包到镜像中,然后解压的方式,可以参考下面博客
Linux安装git和maven——拉取代码 --> mvn打包成jar包 —>运行jar包
配置一下xml设置文件
设置maven的安装路径
输入以下命令进行docker自带的jdk的查找
which java
clean package -Dmaven.test.skip=true -U
docker -v
echo "---------构建成功---------"
[ERROR] Failed to execute goal on project spring-gc-demo: Could not resolve dependencies for project com.tianju:spring-gc-demo:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: org.springframework.boot:spring-boot-starter:jar:2.3.8.RELEASE, org.springframework.boot:spring-boot-autoconfigure:jar:2.3.8.RELEASE, com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.4, org.springframework.boot:spring-boot-starter-tomcat:jar:2.3.8.RELEASE, org.springframework:spring-context:jar:5.2.12.RELEASE: Could not transfer artifact org.springframework.boot:spring-boot-starter:jar:2.3.8.RELEASE from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter/2.3.8.RELEASE/spring-boot-starter-2.3.8.RELEASE.jar: Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.108.215, repo.maven.apache.org/2a04:4e42:8c:0:0:0:0:215] failed: Network unreachable (connect failed) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Build step 'Invoke top-level Maven targets' marked build as failure
解决方法:
配置一下阿里云的地址
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
1.安装docker版本的jenkins;
2.配置jenkins,汉化,配置mvn,配置jdk;
3.拉取开源代码,进行maven的打包案例;
4.遇到的问题及其解决方案;
更多【java-Jenkins入门——安装docker版的Jenkins & 配置mvn,jdk等 & 使用案例初步 & 遇到的问题及解决】相关视频教程:www.yxfzedu.com