原文链接
服务项所在:
可以通过命令开始停止:
Homebrew is the easiest way to install and manage applications on OS X. Let\’s go through how we
install and configure Jenkins.
install and configure Jenkins.
Installation
Follow the instructions at http://brew.sh/ if you have not had Homebrew installed. Then, let\’s proceed to install Jenkins
$ brew update && brew install jenkins
Jenkins is a Java web application. Download and install the latest Java Runtime Environment manually, or use Homebrew Cask to install it
$ brew cask install java
Starting Jenkins
After Jenkins is installed successfully, follow the instructions to start Jenkins on login
$ ln -sfv /usr/local/opt/jenkins/*.plist ~/Library/LaunchAgents
If you want to configure Jenkins to launch on system startup, for all users on OS X, then copy the plist file to the system Launchd location instead
$ sudo cp -fv /usr/local/opt/jenkins/*.plist /Library/LaunchDaemons
$ sudo chown `whoami` /Library/LaunchDaemons/homebrew.mxcl.jenkins.plist
You can always start Jenkins manually with
$ /usr/local/bin/jenkins
or if you have set up your PATH correctly when installing Homebrew, simply
$ jenkins
Restarting Jenkins
If you have an older version of Jenkins and you are upgrading it, then you can restart it this way:
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
Jenkins Options
The default Jenkins startup command in ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist is very simple.
/usr/bin/java
-Dmail.smtp.starttls.enable=true
-jar
/usr/local/opt/jenkins/libexec/jenkins.war
--httpListenAddress=127.0.0.1
--httpPort=8080
Launchd starts a java command, listening on only the loopback network interface and using the port 8080 and listen to SMTP connection over TLS.
Network Port
8080 is a common network port for web development. Tomcat defaults to 8080. On my machine, I run Gitbucket on 8080. Let\’s change it to “8181”
--httpPort=8080
Java Options
If you have any additional Java runtime options, add them to the configuration file. For example, we want to set:
- Initial and maximum VM size to 1G
- Use CMS garbage collector for more responsive system
- Garbage collect PermGen classes – more details here
- Limit PermGen size
-Xms1G
-Xmx1G
-XX: UseConcMarkSweepGC
-XX: CMSClassUnloadingEnabled
-XX:MaxPermSize=256m
Jenkins Plugins
A fresh Jenkins installation is ready to be used, especially if you only need to manage Java projects. There are many Jenkins plugins that can make Jenkins much more powerful. To access Plugin Manager, go to Jenkins ⇒ Dashboard ⇒ Plugin Manager or the url http://jenkins:8181/pluginManager/available.
The easiest way to install a plugin is to view the list of all published plugins in the Plugin Manager, click and Install and restart Jenkins. To install a plugin manually, copy the plugin-name.hpi file to Jenkin\’s directory. In the Homebrew installation, that will be $HOME/.jenkins/plugins. Restart Jenkins and the plugin will be installed.
These are the plugins I have installed:
Jenkins configuration
Besides the launchd configuration file explained above, all other Jenkins configuration is stored in $HOME/.jenkins. The main configuration file is config.xml. You really should not edit the configuration files by hand. Use the Jenkins web interface to make changes http://jenkins:8181/manage
Upgrading Jenkins
As a continuous integration server, Jenkins itself is frequently updated. You can check if a new version of Jenkins is available
$ brew update && brew outdated jenkins
Upgrading jenkins is as easy as
$ brew upgrade jenkins
Homebrew\’s default behaviour is to keep older versions. If you don\’t need the older versions of Jenkins anymore, you can remove them
$ brew cleanup jenkins
Preserve Configuration And Plugins
You don\’t want to set up Jenkins all over again on every upgrade. The good news is, Jenkins server files and your configuration are in separate locations. Your new Jenkins installation will automatically pick up your existing configurations and plugins at “$HOME/.jenkins”
启动执行脚本目录所在:

安装包所在:
服务项所在:
可以通过命令开始停止:// 方法一:
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist 启动
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist 停止
如果要修改端口,比如7070,可在第8步重启jenkins前执行以下命令修改端口参数
defaults write /Library/Preferences/org.jenkins-ci httpPort 7070
Jenkins默认安装目录:
/users/share/

或者更改目录:
cd 到 /Library/LaunchDaemons 编辑 org.jenkins-ci.plist 更改jenkinshome和username
重启Jenkins即可
然后链接 launchd 配置文件
// 方法二(1):
$ln -sfv /usr/local/opt/jenkins/*.plist ~/Library/LaunchAgents
可以更改此 plist 来进行一些自定义的配置,详细列表可以参考https://wiki.jenkins-ci.org/display/JENKINS/Starting%20and%20Accessing%20Jenkins
如果要其他机器也可以访问,把 plist 里的--httpListenAddress=127.0.0.1删掉即可
修改完后,在终端执行
// 方法二(2)
$launchctl load ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
即可启动 Jenkins
接着用浏览器访问
localhost:8080(默认配置),就可以看到 Jenkins 的 web 界面了# 这种方式安装的Jenkins默认目录是/usr/local/Cellar/jenkins/1.651/libexec/....
#所以想让其他局域网用户访问则需要修改/etc/apache2/httpd.conf的ServerRoot 路径
改为/usr/local/Cellar/ 即可
进入 系统管理-启用安全-访问控制-Jenkins专有用户数据库-安全矩阵 添加一个用户:

保存之后会在Jenkins安装目录下生成config.xml文件.

<useSecurity>trueuseSecurity> 这个节点表示使用安全管理,也就是需要用户登录才能操作
用刚才添加的用户进行注册,不使用密码登录可以
<useSecurity>falseuseSecurity>
即可.
评论
发表评论