一. 安装JENKINS
第一种是直接在http://jenkins-ci.org/ 页面上下载jenkins for windows 的安装包. 下载好之后运行exe文件即可.
第二种是下载jenkins的war包, 用java命令执行war包, 如java -jar jenkins.war, 运行时可以在后面添加一些参数,例如-httpPort=8082等等,这种情况就是防止端口被占用, 具体的参数列表如下
(war包可以放到任何目录下,先进入该目录中,然后再执行java -jar jenkins.war -httpPort=8089即可)
--httpPort=$HTTP_PORT | Runs Jenkins listener on port $HTTP_PORT using standard http protocol. The default is port 8080. To disable (because you're using https), use port -1. |
--httpListenAddress=$HTTP_HOST | Binds Jenkins to the IP address represented by $HTTP_HOST. The default is 0.0.0.0 — i.e. listening on all available interfaces. For example, to only listen for requests from localhost, you could use: --httpListenAddress=127.0.0.1 |
--httpsPort=$HTTP_PORT | Uses HTTPS protocol on port $HTTP_PORT |
--httpsListenAddress=$HTTPS_HOST | Binds Jenkins to listen for HTTPS requests on the IP address represented by $HTTPS_HOST. |
--ajp13Port=$AJP_PORT | Runs Jenkins listener on port $AJP_PORT using standard AJP13 protocol. The default is port 8009. To disable (because you're using https), use port -1. |
--ajp13ListenAddress=$AJP_HOST | Binds Jenkins to the IP address represented by $AJP_HOST. The default is 0.0.0.0 — i.e. listening on all available interfaces. |
--argumentsRealm.passwd.$ADMIN_USER | Sets the password for user $ADMIN_USER. If Jenkins security is turned on, you must log in as the $ADMIN_USER in order to configure Jenkins or a Jenkins project. NOTE: You must also specify that this user has an admin role. (See next argument below). |
--argumentsRealm.roles.$ADMIN_USER=admin | Sets that $ADMIN_USER is an administrative user and can configure Jenkins if Jenkins' security is turned on. SeeSecuring Jenkins for more information. |
-Xdebug -Xrunjdwp:transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=n | Sets debugging on and you can access debug on $DEBUG_PORT. |
-logfile=$LOG_PATH/winstone_`date +"%Y%m-%d_%H-%M"`.log | Logging to desired file |
-XX:PermSize=512M -XX:MaxPermSize=2048M -Xmn128M -Xms1024M -Xmx2048M | referring to these options for Oracle Java |
二、Windows服务
运行完了之后,进入jenkins系统: http://localhost:8089(我设的端口号是8089,默认为8080,但我的sitescope已经占用了这个端口)
选择菜单左边的管理JENKINS(Manage Jenkins), 找到安装windows服务(install as windows service)
三、配置JENKINS
在之前先安装几个插件. deploy plugin. (GIT plugin) optional
安装插件的方法: 系统管理->插件管理->可选插件, 在里面找到所需要的,下接点安装就好了
1. 建立一个job, 一般都是选择maven 项目. 如果你的项目没有用maven管理, 我还是建议你用吧.
2. 进去第二个页面后, 在这里就要设置源代码管理工具, svn,git(用git之前要为jenkins装一个git 的plugin)等, 设置好你的源代码路径,设置好你的credential(用户名,密码), ssh key
3. 设置job schedule, 点击页面上POLL SCM就显示出输入框,在里面输入你的计划. 例如我的是H/30 * * * * 每半小时查询一下是否有更新,如果有就开始构建.
4. 自动构建的设置就已经完成了, 构建完的目标文件会存在$JENKINS_HOME$\jobs\$your_job_name$\workspace\target\ 这里.
5. 如果需要自动部署的话,还需要配置一下. 在构建后操作那里, 选中deploy war/ear, 文件路径要选报相对路径,例如target/test.war, Context path里面填写你的项目名称, 之后再输入服务器的用户名密码等.如果用tomcat的话,需要用户具有manager-secret权限.之后再写上服务器URL
原文地址:http://lvjun106.iteye.com/blog/1867118