Install Jenkins on CentOS

Posted by Echo Yuan on July 28, 2017

话不多说,提高生产力的工具要先行,怎么能忍受项目需要人工来打包和发布这件事。

Jenkins官网在

  1. 首先查看Linux的发行版信息
     # lsb_release -a
     LSB Version:     :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
     Distributor ID:     CentOS
     Description:     CentOS release 6.5 (Final)
     Release:     6.5
     Codename:     Final
    

    其实我也不知道lsb_release是啥意思

     # lsb_release -h
     FSG lsb_release v2.0 prints certain LSB (Linux Standard Base) and Distribution information.
    
  2. 参照https://pkg.jenkins.io/redhat-stable/里的步骤执行。
     sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
     sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
    

    注意你要install的Jenkins的版本要和你的JDK版本相适应

    • 2.54 (2017-04) and newer: Java 8
    • 1.612 (2015-05) and newer: Java 7

    With that set up, the Jenkins package can be installed with:

     yum install jenkins
    
  3. Jenkins的Web UI默认是8080端口,我们改一下吧。修改/etc/sysconfig/jenkins文件里的JENKINS_PORT="8080"即可,这个跟官方文档里描述的不一样,因为不同的Linux发行版的原因。我是参考的这里

  4. Start/Stop
    sudo service jenkins start/stop/restart
    sudo chkconfig jenkins on
    

    但是我这启动失败了

     Starting Jenkins bash: /usr/bin/java: No such file or directory
                                                                [FAILED]
    

    之前在机器上装JDK的人不走寻常路哇,只好自己建个软链接了。

  5. 访问http://x.x.x.x:18080,提示要等一会儿,Jenkins正在准备。

  6. Unlock Jenkins via Administrator password Unlock Jenkins

  7. Customize Jenkins,初次使用那就Install suggested plugins好了 Customize Jenkins

  8. Getting started. Getting started

    在网络面板中可以看到不停的有http://x.x.x.x:18080/updateCenter/installStatus?_=1501158675689之类的请求在发出,挺消耗系统资源的。

    如果install plugins操作没有完成(我是直接关掉了页面,因为安装过程太慢了,可能跟服务器的网络有关),那再次进入http://x.x.x.x:18080时会到Unlock Jenkins那步。

  9. If installation failures Installation failures

    第二天来了继续访问http://x.x.x.x:18080,其实我是点的Retry,结果就直接进去了,没有try。

  10. Create first admin user Create first admin user

  11. Welcome to Jenkins! Welcome to Jenkins

  12. Still install failed plugins before on http://x.x.x.x:18080/pluginManager/ page.