自己想在Ubunt 22.04 服务器上重装jenkins 卸载完后 重装发现启动的端口不是默认的8080端口,网上找的资料都不是很全,所以自己记录下。
自己装过的版本
1.先停掉jenkins服务
sudo systemctl stop jenkins
2.取消Jenkins自启动和卸载
sudo systemctl disable jenkins
sudo apt-get remove jenkins
3.卸载jenkins相关配置
sudo apt purge jenkins
sudo apt purge --auto-remove jenkins
4.关键的地方来了,搞完上面3步还没完。这样操作jenkins还是有很多残留的文件的,如果不删除,当你重新安装jenkins后会发现之前修改完jenkins的端口还是出现了,不是默认的8080.
# 切换root用户
su root
# 进入根目录
cd /
# 查看有关jenkins文件夹
find / -iname "*jenkins*"
5. 不是把查出来有关的jenkins文件都删除掉,如果服务器此时也装了gitlab 也会扫描出来的。
具体问题具体分析。
root@MyUbuntu:~# find / -iname "*jenkins*"
/opt/gitlab/embedded/lib/ruby/gems/3.1.0/gems/danger-9.4.2/lib/danger/ci_source/jenkins.rb
/opt/gitlab/embedded/service/mattermost/prepackaged_plugins/mattermost-plugin-jenkins-v1.1.0-linux-amd64.tar.gz.sig
/opt/gitlab/embedded/service/mattermost/prepackaged_plugins/mattermost-plugin-jenkins-v1.1.0-linux-amd64.tar.gz
/opt/gitlab/embedded/service/gitlab-rails/doc/integration/jenkins.md
/opt/gitlab/embedded/service/gitlab-rails/doc/integration/img/jenkins_gitlab_plugin_config.png
/opt/gitlab/embedded/service/gitlab-rails/doc/ci/migration/examples/jenkins-maven.md
/opt/gitlab/embedded/service/gitlab-rails/doc/ci/migration/jenkins.md
/opt/gitlab/embedded/service/gitlab-rails/doc/development/integrations/jenkins.md
/opt/gitlab/embedded/service/gitlab-rails/app/models/integrations/jenkins.rb
/opt/gitlab/embedded/service/gitlab-rails/config/metrics/counts_all/20210216175939_projects_inheriting_jenkins_active.yml
/opt/gitlab/embedded/service/gitlab-rails/config/metrics/counts_all/20210216175937_instances_jenkins_active.yml
/opt/gitlab/embedded/service/gitlab-rails/config/metrics/counts_all/20210216175932_projects_jenkins_active.yml
/opt/gitlab/embedded/service/gitlab-rails/config/metrics/counts_all/20210216175941_groups_inheriting_jenkins_active.yml
/opt/gitlab/embedded/service/gitlab-rails/config/metrics/counts_all/20210216175934_groups_jenkins_active.yml
/opt/gitlab/embedded/service/gitlab-rails/config/metrics/counts_all/20210216175935_templates_jenkins_active.yml
/etc/systemd/system/jenkins.service.d
/etc/apt/sources.list.d/jenkins.list
/home/honor/Downloads/jenkins.war
/root/.jenkins/
find: ‘/run/user/1000/doc’: 权限不够
find: ‘/run/user/1000/gvfs’: 权限不够
/usr/share/keyrings/jenkins-keyring.asc
/var/cache/apt/archives/jenkins_2.164.1_all.deb
/var/cache/apt/archives/jenkins_2.138.1_all.deb
/var/cache/apt/archives/jenkins_2.346.1_all.deb
/var/cache/apt/archives/jenkins_2.440.2_all.deb
/var/lib/jenkins
/var/cache/jenkins
/var/lib/apt/lists/pkg.jenkins.io_debian-stable_binary_Release
/var/lib/apt/lists/pkg.jenkins.io_debian-stable_binary_Release.gpg
/var/lib/apt/lists/pkg.jenkins.io_debian-stable_binary_Packages
/var/crash/jenkins.0.crash
find: ‘/tmp/.mount_Qv2raye9zMPQ’: 权限不够
/tmp/hsperfdata_jenkins
6.根据自己的情况来删除,我删除下面几个文件夹
# 缓存相关
sudo rm -rf /root/.jenkins/
sudo rm -r /var/lib/jenkins
sudo rm -r /var/cache/jenkins
# 服务启动
sudo rm -rf /etc/systemd/system/jenkins.service.d
7.重新安装jenkins,我是指定版本安装
root@MyUbuntu:~# sudo apt-get install jenkins=2.440.2
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
下列【新】软件包将被安装:
jenkins
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 27 个软件包未被升级。
需要下载 0 B/85.8 MB 的归档。
解压缩后会消耗 86.6 MB 的额外空间。
正在选中未选择的软件包 jenkins。
(正在读取数据库 ... 系统当前共安装有 310405 个文件和目录。)
准备解压 .../jenkins_2.440.2_all.deb ...
正在解压 jenkins (2.440.2) ...
正在设置 jenkins (2.440.2) ...
Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /lib/systemd/system/jenkins.service.
8.看下状态,没有问题,完成。端口号也是默认的8080.