标签:9.png AC releases 直接 rpm包 code download src man
1、安装配置java环境
# tar xvf jdk-8u111-linux-x64.tar.gz -C /usr/local/src/
# ln -sv /usr/local/src/jdk1.8.0_111 /usr/local/jdk
# vim /etc/profile
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
# source /etc/profile && java –version
# rpm –ivh jdk-8u111-linux-x64.rpm
# yum install java-1.8.0-openjdk-1.8.0 -y
2、安装Jenkins
# rpm –ivh https://pkg.jenkins.io/redhat/jenkins-2.27-1.1.noarch.rpm
# /etc/init.d/jenkins start
# chkconfig jenkins on
3、配置Jenkins
# vim /etc/sysconfig/jenkins
JENKINS_HOME=“/var/lib/jenkins“ #数据目录,使用高IO大容量磁盘
JENKINS_USER=“jenkins“ #启动用户
JENKINS_PORT=“8080“ #启动端口
4、访问web界面
5、安装插件
6、手动安装插件
# cd /var/lib/jenkins/plugins
# tar xvf jenkins_plugin.tar.gz #打包的一个插件包,展开即可使用插件
# chown jenkins.jenkins ./* -R
# /etc/init.d/jenkins start
http://updates.jenkins-ci.org/download/plugins/
7、创建用户
8、登陆
9、邮件配置
10、发送邮件设置
11、配置从gitlab上拉取代码
gitlab Plugin gitlab Hook Plugin
12、添加Git用户
参考此文档配置:http://www.cnblogs.com/python-gm/p/8883515.html
13、Jenkins上添加一个认证用户
配置地址:http://172.20.3.206:8080/credentials/store/system/domain/_/newCredentials
14、Jenkins创建项目
15、配置Jenkins项目详细信息
16、部署代码检测工具:Sonar
# tar xvf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
# ln -sv /usr/local/src/mysql-5.6.34-linux-glibc2.5-x86_64 /usr/local/mysql
# cd /usr/local/mysql/
# useradd mysql -s /sbin/nologin
# chown -R mysql.mysql ./* -R
# mkdir /data && chown mysql.mysql /data/ -R
# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/ --basedir=/usr/local/mysql/
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
# cp /usr/local/mysql/my.cnf /etc/my.cnf
# vim /etc/my.cnf
basedir = /usr/local/mysql
datadir = /data
port = 3306
# /etc/init.d/mysql start
#ln -sv /usr/local/mysql/bin/mysql /usr/bin/
# /usr/local/mysql/bin/mysql
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL ON sonar.* TO sonar@"jenkins-server.com.cn" IDENTIFIED BY "123456";
GRANT ALL ON sonar.* TO sonar@"192.168.10.%" IDENTIFIED BY "123456";
FLUSH PRIVILEGES;
/usr/local/mysql/bin/mysql -usonar -p123456 -h192.168.10.131
### sonar依赖于java环境,而且java版本必须是1.8版本或更高,否则sonar启动失败
# unzip sonarqube-5.6.zip
# ln -sv /usr/local/src/sonarqube-5.6 /usr/local/sonar
# grep "^[za-Z]" /usr/local/sonar/conf/sonar.properties
sonar.jdbc.username=sonar
sonar.jdbc.password=123456
sonar.jdbc.url=jdbc:mysql://192.168.10.131:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.web.port=8800
# /usr/local/sonar/bin/linux-x86-64/sonar.sh start
wget https://github.com/SonarQubeCommunity/sonar-l10n-zh/releases/download/sonar-l10n-zh-plugin-1.11/sonar-l10n-zh-plugin-1.11.jar
# /usr/local/sonarqube-5.6/bin/linux-x86-64/sonar.sh restart
17、部署扫描器
# 下载地址:http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
# unzip sonar-scanner-2.6.1.zip
# ln -sv /usr/local/src/sonar-scanner-2.6.1 /usr/local/sonar-scanner
# cd /usr/local/sonar-scanner/
# grep "^[a-Z]" conf/sonar-scanner.properties
sonar.host.url=http://localhost:8800
sonar.sourceEncoding=UTF-8
sonar.jdbc.username=sonar
sonar.jdbc.password=123456
sonar.jdbc.url=jdbc:mysql://192.168.10.131:3306/sonar?useUnicode=true&characterEncoding=utf8
18、jenkins关联到sonar和sonar-scanner
20、项目配置扫描功能
sonar.projectKey=test-demo
sonar.projectName=test-demo
sonar.projectVersion=1.0
sonar.sources=./
sonar.language=java|php|python #(java|php|python 需要在sonar中安装对应的java|php|python语言包)
sonar.sourceEncoding=UTF-8
21、构建失败邮件通知
标签:9.png AC releases 直接 rpm包 code download src man
原文地址:https://www.cnblogs.com/python-gm/p/8884125.html