Jenkins安装——Yum安装和Docker安装

Jenkins安装

Yum安装Jenkins

要在CentOS 7上安装Jenkins,您可以按照以下步骤进行操作:

  1. 更新系统软件包:
sudo yum update
  1. 安装Java Development Kit (JDK)。Jenkins需要Java来运行。您可以选择安装OpenJDK或Oracle JDK。以下是安装OpenJDK的示例命令:
sudo  yum install fontconfig java-11-openjdk
  1. 导入Jenkins存储库的GPG密钥:
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key --no-check-certificate
  1. 安装Jenkins:
sudo yum install jenkins
  1. 启动Jenkins服务:
sudo systemctl start jenkins && sudo systemctl daemon-reload
  1. 配置Jenkins开机自启动:
sudo systemctl enable jenkins
  1. 打开防火墙端口以允许访问Jenkins的Web界面:
sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
sudo firewall-cmd --reload

现在,您可以通过在Web浏览器中输入http://your_server_ip:8080来访问Jenkins的Web界面,并按照屏幕上的指示完成Jenkins的安装设置。

请注意,安装Jenkins可能需要一些时间,具体取决于您的互联网连接速度和系统配置。

查看密码

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Docker安装Jenkins

docker run \
   -u root \
   --rm \
   -d \
   -p 8080:8080 \
   -p 50000:50000 \
   -v jenkins-data:/var/jenkins_home \
   -v /var/run/docker.sock:/var/run/docker.sock \
   jenkinsci/blueocean
   
Unable to find image 'jenkinsci/blueocean:latest' locally
latest: Pulling from jenkinsci/blueocean
213ec9aee27d: Pull complete 
9fb6b045bfc8: Pull complete 
1a7d7223e42d: Pull complete 
8f2b061b68da: Pull complete 
bba48a821480: Pull complete 
0061c72f26bd: Pull complete 
f65ed3fbea93: Pull complete 
3509f53c6b7b: Pull complete 
28ea9c56d127: Pull complete 
b3b3ea5ca7f4: Pull complete 
e5ecc395b9e7: Pull complete 
a4cea1bad4ff: Pull complete 
d2d0e6e9298c: Pull complete 
f786c314ed83: Pull complete 
Digest: sha256:f27933313986f7fb0b5784aa6520ebddc455ce258cbf4d13a3e3cf9d4c94d992
Status: Downloaded newer image for jenkinsci/blueocean:latest
3f48f3cace6f56061dc2ba8d4d49a55e58d6c36a5dd40ac239a7715fa11f8883   

启动起来,访问ip:8080

Jenkins安装——Yum安装和Docker安装_第1张图片

查看密码

[root@test jvm]# docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED         STATUS         PORTS                                                                                      NAMES
3f48f3cace6f   jenkinsci/blueocean   "/sbin/tini -- /usr/…"   4 minutes ago   Up 4 minutes   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 0.0.0.0:50000->50000/tcp, :::50000->50000/tcp   compassionate_torvalds
23b7595758f6   app:0.0.1             "/bin/sh -c 'java -j…"   3 days ago      Up 3 days      0.0.0.0:8888->8888/tcp, :::8888->8888/tcp                                                  pedantic_curran

[root@test jvm]# docker exec -it 3f48f3cace6f /bin/bash
bash-5.1# cat /var/jenkins_home/secrets/initialAdminPassword
0e458fdef7d1402186537c3a66428c4a

账户为:admin

密码复制进去

Jenkins安装——Yum安装和Docker安装_第2张图片

安装成功

Jenkins安装——Yum安装和Docker安装_第3张图片

你可能感兴趣的:(Jenkins实战,jenkins,docker,servlet,容器,运维,java)