centos7安装jenkins..

无聊,弄点事情干.
安装方式很多,找个最简单的方式安装.

修改yum源为国内的.(清华大学的.)

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

安装jdk

1.  自己下载二进制包解压安装
    http://openjdk.java.net/install/index.html openjdk主页,下载最新的或者你喜欢的.  `tar xvf openjdk-11.0.1_linux-x64_bin.tar.gz`  然后把 openjdk..in 加入到`PATH`中 `vim  /etc/profile` 等方式  
 2. `yum install java-1.8.0-openjdk -y` 安装,自己会加 PATH的 [√]

安装maven (本次不需要,war文件部署安装才需要)

wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
tar xvf apache-maven-3.6.1-bin.tar.gz
mv apache-maven-3.6.1 /usr/local/maven3

vim /etc/profile

export MAVEN_HOME=/usr/local/maven3
export PATH="${MAVEN_HOME}/bin:$PATH"


source /etc/profile

安装jenkins

wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/jenkins-2.164.3-1.1.noarch.rpm
yum install jenkins-2.164.3-1.1.noarch.rpm
#systemctl enable jenkins --now             systemclt 220之后可以使用这个命令设置自启后启动服务
systemctl enable jenkins
systemctl restart jenkins
#如果jenkins服务起不来的话,systemctl status jenkins 看下原因
: Starting LSB: Jenkins Automation Server...
Aug 30 11:00:22 jenkins runuser[402]: pam_unix(runuser:session): session opened f...0)
Aug 30 11:00:22 jenkins jenkins[397]: Starting Jenkins bash: /usr/bin/java: No su...ry
Aug 30 11:00:22 jenkins runuser[402]: pam_unix(runuser:session): session closed f...ns
Aug 30 11:00:22 jenkins jenkins[397]: [FAILED]
Aug 30 11:00:22 jenkins systemd[1]: jenkins.service: control process exited, code...=1
Aug 30 11:00:22 jenkins systemd[1]: Failed to start LSB: Jenkins Automation Server.
Aug 30 11:00:22 jenkins systemd[1]: Unit jenkins.service entered failed state.
Aug 30 11:00:22 jenkins systemd[1]: jenkins.service failed.
#这里需要建个软连接
ln -s  /usr/local/jdk-12.0.2/bin/java /usr/bin/java
systemctl restart jenkins

登录jenkins

http://jenkins服务器ip:8080
获取第一次管理员密码
cat /var/lib/jenkins/secrets/initialAdminPassword
登录后设置一个管理员.

配置jdk目录,maven目录

yum -y install java-1.8.0-openjdk-devel.x86_64
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/
/usr/local/maven3

配置国内插件源.

1.进入jenkins系统管理
2.进入插件管理
3.点击高级,修改升级站点的地址为清华大学镜像地址
插件镜像地址
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json

点提交即可,之后刷新下 插件就出来了.

其实下载插件的时候还是到github上去下载的

关于jenkins的反代问题.
https://www.cnblogs.com/lovesKey/p/11520919.html

假设你密码忘记了.
参考这个页面操作
https://blog.csdn.net/wh211212/article/details/76825305

原文地址:https://www.cnblogs.com/lovesKey/p/10908579.html