官方提示native安装方式过时:
方法一:直接使用Uninstall.command命令删除(推荐)
$ /Library/Application\ Support/Jenkins/Uninstall.command
Jenkins uninstallation script
The following commands are executed using sudo, so you need to be logged
in as an administrator. Please provide your password when prompted.
+ sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
Password:
+ sudo rm /Library/LaunchDaemons/org.jenkins-ci.plist
+ sudo rm -rf /Applications/Jenkins '/Library/Application Support/Jenkins' /Library/Documentation/Jenkins
+ sudo rm -rf /Users/Shared/Jenkins
+ sudo rm -rf /var/log/jenkins
+ sudo rm -f /etc/newsyslog.d/jenkins.conf
+ sudo dscl . -delete /Users/jenkins
+ sudo dscl . -delete /Groups/jenkins
+ pkgutil --pkgs
+ grep 'org\.jenkins-ci\.'
+ xargs -n 1 sudo pkgutil --forget
Forgot package 'org.jenkins-ci.support.pkg' on '/'.
Forgot package 'org.jenkins-ci.jenkins21901.postflight.pkg' on '/'.
Forgot package 'org.jenkins-ci.documentation.pkg' on '/'.
Forgot package 'org.jenkins-ci.launchd-jenkins.pkg' on '/'.
Forgot package 'org.jenkins-ci.jenkins.osx.pkg' on '/'.
+ set +x
Jenkins has been uninstalled.
方法二:手动删除(不推荐,因为可能会漏掉某些文件)
1、到应用程序
删除jenkins
整个目录
2、删除jenkins开机启动配置文件
$ rm -f /Library/LaunchDaemons/org.jenkins-ci.plist
3、删除启动命令等文件
$ rm -f /Library/Application Support/Jenkins/jenkins-runner.sh
$ rm -f /Library/Application Support/Jenkins/Uninstall.command
4、删除日志文件目录
$ rm -rf /var/log/jenkins
5、删除配置文件
$ rm -f /etc/newsyslog.d/jenkins.conf
6、删除工作目录
$ rm -rf /Users/Shared/Jenkins
7、删除jenkins用户
系统偏好设置>用户与群组>jenkins
Brew命令安装jenkins
删除完后我们就可以使用brew命令重新安装jenkins了
$ brew install jenkins
brew相关其他命令
安装指定版本:
brew install jenkins@YOUR_VERSION
启动jenkins服务:brew services start jenkins
重启Jenkins服务:brew services restart jenkins
升级jenkins:brew upgrade jenkins
完全卸载jenkins:brew uninstall jenkins --force
brew cleanup
rm -rf /Users/[用户名]/.jenkins
//注意:完全重新安装必须执行这一步,目的是为了删除以前的历史配置,否则以前的配置还在,重装过后还是原来的样子
Brew方式相关路径
Brew方式安装后的工作目录、日志文件、配置文件路径如下:
安装目录:/usr/local/Cellar/jenkins/2.213
配置文件:/usr/local/Cellar/jenkins/2.213/homebrew.mxcl.jenkins.plist
日志路径:待发现
工作目录:~/.jenkins
PKG方式安装相关路径可以参考这里:https://www.bootschool.net/article/5d5775d
修改jenkins默认端口
$ brew services list
Name Status User Plist
jenkins started hfy /Users/luke/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
mongodb-community stopped
mysql stopped
nginx stopped
redis stopped
brew方式安装你可能也会跟我一样找到几个配置文件:
/Users/luke/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
/usr/local/opt/jenkins/homebrew.mxcl.jenkins.plist
/usr/local/Cellar/jenkins/2.213/homebrew.mxcl.jenkins.plist
注意:并不是修改任何一个配置文件都可以成功。
opt
目录下的文件是使用安装目录软链接过去,所以不能修改这个目录下的文件。而LaunchAgents
目录下的配置文件是拷贝过去的,也不能修改这个文件(已试过、但是失败了)。最后剩下的就是安装目录下的配置文件了,修改这个文件能够成功,并且其它目录下的都会被这个文件覆盖掉。
$ vi /usr/local/Cellar/jenkins/2.213/homebrew.mxcl.jenkins.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.jenkins</string>
<key>ProgramArguments</key>
<array>
<string>/usr/libexec/java_home</string>
<string>-v</string>
<string>1.8</string>
<string>--exec</string>
<string>java</string>
<string>-Dmail.smtp.starttls.enable=true</string>
<string>-jar</string>
<string>/usr/local/opt/jenkins/libexec/jenkins.war</string>
<string>--httpListenAddress=127.0.0.1</string>
<string>--httpPort=8888</string> //在这里修改端口号即可
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
修改完后记得重启服务
$ brew services restart jenkins
jenkins插件加速
$ cd /Users/[用户名]/.jenkins/updates #进入更新的配置文件所在位置
或者
$ cd ~/.jenkins/updates
$ cp default.json default.json_backup //备份默认配置文件
使用sed替换内容:
$ sed -i 's#http://updates.jenkins-ci.org/download#https://mirrors.tuna.tsinghua.edu.cn/jenkins#g' default.json && sed -i 's#http://www.google.com#https://www.baidu.com#g' default.json
修改完后保存并重启jenkins即可。