0
点赞
收藏
分享

微信扫一扫

利用Jenkins配置自动化构建

Raow1 2022-11-11 阅读 107


 

1. 安装

  • sudo wget -O /etc/yum.repos.d/jenkins.repo ​​http://pkg.jenkins-ci.org/redhat/jenkins.repo​​
  • sudo rpm --import ​​http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key​​
  • sudo yum install jenkins

2. 服务启动/停止/重启

  • sudo service jenkins start/stop/restart
  • /etc/sysconfig/jenkins,设置以下目录为jenkins用户所有: /var/log/jenkins, /var/lib/jenkins, and /var/cache/jenkins。

    默认端口8080



    运行前需要安装jre



 



3. 安全策略



    用户认证和权限控制两种维度



    (1). 使用jenkins自身数据库,允许用户注册,待注册完admin后户后取消选择此项;



    (2). 项目矩阵授权策略



 



4. PHP项目构建



    安装plguin phing插件(jenkins && 服务器同时安装)



    系统设置进行插件配置



 



    新建一自由风格项目



     启用项目安全(添加项目使用人)



     参数化构建过程 (默认当前最新版本)



     源码管理(svn信息配置)



    构建



        Invoke Phing targets



        配置phing 及 build.xml 文件



        Post build task可以待构建后监听输出成功文本,执行同步rsync脚本



 



5. Java项目构建



    安装ant插件



    新建一自由风格项目



        启用项目安全(添加项目使用人)



        参数化构建过程 (默认当前最新版本)



        源码管理(svn信息配置)



    构建



         Invoke Ant



         配置ant 及 build.xml 文件



Post build task可以待构建后监听输出成功文本,执行同步rsync脚本

 

 

############## 20150911 补充内容 ###############

   对于启动错误

 

$ /etc/init.d/jenkins start
Starting jenkins (via systemctl): Job for jenkins.service failed. See 'systemctl status jenkins.service' and 'journalctl -xn' for details. [FAILED]

   存在以下几种可能:

    1. java 环境没有安装成功,可以通过java -version 验证

 



$ java -version java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)



    2. 配置项调整

     通过启动错误log确定是否jenkins home目录没有创建,或者启动端口是否被占用等问题。

 


systemctl status jenkins.service
jenkins.service - LSB: Jenkins Continuous Integration Server
Loaded: loaded (/etc/rc.d/init.d/jenkins)
Active: failed (Result: exit-code) since Fri 2015-09-11 13:46:07 CST; 15s ago
Process: 3120 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)

Sep 11 13:46:07 iZ25k1i5wxtZ systemd[1]: Starting LSB: Jenkins Continuous Integration Server...
Sep 11 13:46:07 iZ25k1i5wxtZ jenkins[3120]: JENKINS_HOME directory does not exist: /usr/local/jenkins
Sep 11 13:46:07 iZ25k1i5wxtZ systemd[1]: jenkins.service: control process exited, code=exited status=1
Sep 11 13:46:07 iZ25k1i5wxtZ systemd[1]: Failed to start LSB: Jenkins Continuous Integration Server.
Sep 11 13:46:07 iZ25k1i5wxtZ systemd[1]: Unit jenkins.service entered failed state.


举报

相关推荐

0 条评论