一、安装jdk
yum install java-1.8.0-openjdk
vim /etc/profile
在profile文件中添加如下内容
#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64
JRE_HOME= J A V A H O M E / j r e C L A S S P A T H = . : JAVA_HOME/jre CLASS_PATH=.: JAVAHOME/jreCLASSPATH=.:JAVA_HOME/lib/dt.jar: J A V A H O M E / l i b / t o o l s . j a r : JAVA_HOME/lib/tools.jar: JAVAHOME/lib/tools.jar:JRE_HOME/lib
PATH= P A T H : PATH: PATH:JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效
二、下载jenkins的rpm包
wget https://prodjenkinsreleases.blob.core.windows.net/redhat-stable/jenkins-2.46.3-1.1.noarch.rpm
安装rpm包
sudo rpm -ivh jenkins-2.46.3-1.1.noarch.rpm
三、修改jenkins配置文件,将正确的jdk路径写入
sudo vim /etc/init.d/jenkins
sudo service jenkins restart
四、jenkins进行配置
将下面的文件中的密码输入
sudo cat initialAdminPassword
配置用户名密码
用户:admin
密码:qgtechadmin
ok complate! let us to play
if you think this is over ,that is a joker
五、jenkins重启遇到的错误与解决
Starting jenkins (via systemctl): Warning: jenkins.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
使用以下命令解决:sudo systemctl daemon-reload
jekins日志文件位置: /var/log/jenkins/jenkins.log
六、安装sun的jdk
wget http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz?AuthParam=1523178968_30955ac9b8ce68136c644fa50e7f960e
mv JDKXXXXXXX jdk1.8.tar.gz
sudo tar -xvf jdk1.8.tar.gz -C /usr/lib/jvm/java
在jenkins中的 Global Tool Configuration 配置
七、安装git
techsunadminChunlinj123
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
wget https://github.com/git/git/archive/v2.3.0.zip
#参数-d 后边的是解压到的目录
unzip v2.3.0 -d git
cd git-2.3.0/
make prefix=/usr/local/git all
sudo make prefix=/usr/local/git install
修改配置文件
sudo vim /etc/profile #编辑profile文件
export PATH=/usr/local/git/bin:$PATH
source /etc/profile
八、maven安装
sudo vim /etc/profile
source /etc/profile
mvn -version
解决apache-maven-3.5.3 is not a directory on the Jenkins master
给与jenkins目录权限
sudo chown jenkins:jenkins /home/qgtech/tools/apache-maven-3.5.3
在jenkins中选择插件管理,搜索Maven Integration,进行插件安装,记得重启jenkins
九、解决jenkins中遇到的疑难杂症
在创建项目输入git地址后出现403错误:
No valid crumb was included in the request
解决方法:
勾选掉防止跨站点请求伪造
解决方法:
ssh-keygen -t rsa -C "[email protected]"
cd ~
cd ./ssh
cat ~/.ssh/id_rsa.pub
将ssh key 放在git账号中配置一下就好
给jenkins权限
chown jenkins id_rsa.pub
chown jenkins id_rsa
在jenkins上配置ssh的认证
这里可能依旧报错,原因有2个,一个是git账号没有下载权限,一个是jenkins读取不到公钥
解决掉第一个问题后,将安装jenkins的用户下的 ~/.ssh/下也放入生成的公钥私钥,root账号也放一份,在jenkins上保存一下设置,发现问题就好了
十、安装tomcat
wget http://apache.mirrors.ionfish.org/tomcat/tomcat-8/v8.5.29/bin/apache-tomcat-8.5.29-deployer.tar.gz
sudo groupadd tomcat
sudo mkdir /opt/tomcat
sudo useradd -s /bin/nologin -g tomcat -d /opt/tomcat tomcat
sudo tar -zxvf apache-tomcat-8.0.33.tar.gz -C /opt/tomcat --strip-components=1
cd /opt/tomcat
sudo chmod -R tomcat .
sudo chgrp -R tomcat conf
sudo chmod g+rwx conf
sudo chmod g+r conf/*
sudo chown -R tomcat logs/ temp/ webapps/ work/