How to install Jenkins with Docker

Docker install Jenkins

1. Introduction to Jenkins

Jenkins 是一款流行的开源持续集成(Continuous Integration)工具,广泛用于项目开发,具有自动化构建、测试和部署等功能。   
Official website: http://jenkins-ci.org/

2. Features of Jenkins

1. 开源的Java语言开发持续集成工具,支持持续集成,持续部署。

2. 易于安装部署配置:可通过yum安装,或下载war包以及通过docker容器等快速实现安装部署,可方便web界面配置管理。

3. 消息通知及测试报告:集成RSS/E-mail通过RSS发布构建结果或当构建完成时通过e-mail通知,生成JUnit/TestNG测试报告。

4. 分布式构建:支持Jenkins能够让多台计算机一起构建/测试。

5. 文件识别:Jenkins能够跟踪哪次构建生成哪些jar,哪次构建使用哪个版本的jar等。

6. 丰富的插件支持:支持扩展插件,你可以开发适合自己团队使用的工具,如git, svn, maven, ssh, docker等。

3. Jenkins installation and continuous integration environment configuration

1. Pull the Jenkins image

docker pull jenkins/jenkins

2. Create a Jenkins folder and enable read and write permissions

mkdir -p /home/jenkins_home
chmod 777 /home/jenkins_home

3. Check the Docker image to see if Jenkins exists

docker images

4. Start the Jenkins service (Note: jenkinsci/blueocean-lts-centos specifies the image version)

docker run -d --name jenkins -p 8080:8080 -p 50000:50000 -v /home/jenkins_home:/var/jenkins_home  jenkinsci/blueocean-lts-centos

5. View the initialization password

image.png

docker exec -it jenkins bash
cat /var/jenkins_home/secrets/initialAdminPassword

6. Configure the Jenkins URL (the default is the external access URL set at the beginning, which can be customized)

http://xx.xx.xx.xxx:8060/

7. Custom url needs to restart Jenkins service

docker stop jenkins
docker rm jenkins
(重新启动可以加上 -v Maven与Jdk的位置)
docker run -d --name jenkins -p 8060:8080 -p 50000:50000 -v /home/jenkins_home:/var/jenkins_home jenkinsci/blueocean

8. Re-open Jinkens and log in with your account to enter the home page

image.png

9. Open the plug-in management in the system management and download related service plug-ins

image.png

1. Publish Over SSH
2. SSH
3. Maven Integration plugin
4. 若是使用 gitleb, gitee等代码托管平台 需要下载构建触发器

10. Open system configuration in system management

1. gitee配置 方便项目的部署(推荐配置自己所搭建的代码托管平台)

image.png

2. ssh 服务的密钥与配置信息

image.png

3. 创建一个mavne项目

image.png

4. 进行项目的配置

image.png

5. 项目的代码管理地址与版本分支的配置

image.png

6. 填写项目源码的地址

image.png

7. 在构建开始之前删除工作区(根据项目需要可进行配置)

image.png

8. 指定jdk版本(需要在系统配置中配置)

image.png

9. 自定义构建前与构建后的项目的shell脚本

10. 选择指定分支,启动项目

image.png

End

Guess you like

Origin blog.csdn.net/weixin_43869435/article/details/125481114
Recommended