centos install jenkins

prepare: install JDK

install

1
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
1
rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

如果不能安装就到官网下载jenkis的rmp包,官网地址(http://pkg.jenkins-ci.org/redhat-stable/)
一. 官方下载地址:https://jenkins.io/download/
二. 镜像下载地址:http://mirrors.jenkins-ci.org/

1
2
3
 wget  http://mirror.serverion.com/jenkins/redhat-stable/jenkins-2.235.1-1.1.noarch.rpm
rpm -ivh jenkins-2.222.3-1.1.noarch.rpm
yum install -y jenkins-2.222.3-1.1.noarch.rpm
1
yum install -y jenkins

配置jenkis的端口

1
vim /etc/sysconfig/jenkins
1
2
找到修改端口号:
JENKINS_PORT="8080" 此端口不冲突可以不修改

modify mirror of update center

https://www.jianshu.com/p/fb1bff7a21a1

vim /var/lib/Jenkins/hudson.model.UpdateCenter.xml

1
2
3
4
5
6
7
8
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
</site>
</sites>

config jenkins jdk

vim /etc/init.d/jenkins

1
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/bin/java

启动jenkins

1
systemctl  start/stop/restart jenkins

开机启动

1
systemctl enable jenkins.service
  • su jenkins
    1
    su -s /bin/bash jenkins 

配置Jenkins,run webserver

全局工具配置

  • git: /usr/local/git/bin/git
  • Jdk: /usr/local/java/jdk1.8.0_211
  • maven_home : /usr/local/maven

user Jenkins git ssh

使用 jenkins 自动生成的账号

1
su -s /bin/bash jenkins 

生成ssh 公钥,私钥

1
ssh-keygen -t rsa -C "469608976@qq.com"

install plugin

  • maven integration plugin
  • deploy to container plugin
  • github

create Jenkins project

  • config git
  • maven
    1
    clean package -Dmaven.test.skip=true
  • shell

    sh /usr/scripts/webserver.sh
    1
    2
    3
    4
    echo "this is webserver.sh"
    echo "this is webserver"
    chmod u=rwx,og=rwx /var/lib/jenkins/workspace/webserver/target/webserver-0.0.1-SNAPSHOT.jar
    nohup java -jar /var/lib/jenkins/workspace/webserver/target/webserver-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &

参考文档

评论