我们要将jenkins结合gitlab使用,那就还需要安装一个git工具。
[root@jenkins updates]# yum install git -y
[root@jenkins ~]# yum -y install java-1.8.0-openjdk* -y
[root@jenkins ~]# java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
配置JAVA_HOME:
[root@jenkins1 ~]# echo -e "export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64\nexport CL=$PATH:$JAVA_HOME/bin" >> /etc/profile
[root@jenkins1 ~]# source /etc/profile
[root@jenkins ~]# wget https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.1.1/apache-maven-3.1.1-bin.tar.gz
[root@jenkins ~]# tar xvf apache-maven-3.1.1-bin.tar.gz
[root@jenkins ~]# cp -r apache-maven-3.1.1 /usr/local/apache-maven
[root@jenkins ~]# echo -e "export MAVEN_HOME=/usr/local/apache-maven\nexport PATH=/usr/local/apache-maven/bin:$PATH" >> /etc/profile
[root@jenkins ~]# source /etc/profile
[root@jenkins ~]# mvn -version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 23:22:22+0800)
Maven home: /usr/local/apache-maven
Java version: 1.8.0_242, vendor: Oracle Corporation
...
[root@jenkins ~]# wget http://pkg.jenkins.io/redhat/jenkins-2.230-1.1.noarch.rpm
这个连接是jenkins外国的服务器,国内访问会特别慢,这里我们使用国内清华的源:
[root@jenkins ~]# wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/jenkins-2.220-1.1.noarch.rpm
[root@jenkins ~]# rpm -ivh jenkins-2.220-1.1.noarch.rpm
[root@jenkins ~]# systemctl start jenkins
到这里jenkins就已经安装上了,但是我们使用jenkins下载插件的时候会特别慢,因为访问的是国外的网站,这里需要修改一下配置: 进入updates目录前要多等一会,jenkins正在安装,update目录有可能还没有生成:
[root@jenkins ~]# cd /var/lib/jenkins/updates
[root@jenkins updates]# sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
[root@jenkins updates]# sed -i 's/https:\/\/updates.jenkins.io/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins\/updates/' /var/lib/jenkins/hudson.model.UpdateCenter.xml
重启jenkins:
[root@jenkins updates]# systemctl restart jenkins
浏览器登录:http://192.168.12.26:8080
出现如下界面,我们需要等待页面跳转:
[root@jenkins26 jenkins]#
[root@jenkins26 jenkins]# cat /var/lib/jenkins/secrets/initialAdminPassword
8dc05642036044d7b6d7d24c0abaecb9