centos7.x安装jenkins

1
2
3
4
5
#jdk
tar -zxf jdk-8u131-linux-x64.tar.gz -C /usr/local/
echo "export JAVA_HOME=/usr/local/jdk1.8.0_131" >> /etc/profile
#echo "export PATH=$PATH:$JAVA_HOME/bin" >> /etc/profile
ln -sf $JAVA_HOME/bin/java /usr/bin/java
1
2
3
4
5
#maven安装
#### http://maven.apache.org/download.cgi
wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
tar -zxf apache-maven-3.3.9-bin.tar.gz  -C /usr/local/
echo "export MAVEN_HOME=/usr/local/apache-maven-3.3.9" >> /etc/profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#RedHat Linux RPM packages for Jenkins 安装稳定版Jenkins 2.46.3
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
#安装
yum install jenkins git -y
 
#更改默认端口8080 改为8000
#vim /etc/sysconfig/jenkins 
sed -i 's#JENKINS_PORT=\"8080\"#JENKINS_PORT=\"8000\"#'  /etc/sysconfig/jenkins 
 
#/usr/lib/jenkins/  安装目录
#/var/lib/jenkins/  工作目录
 
#添加JENKINS_HOME
#vim /etc/profile
echo "export JENKINS_HOME=/var/lib/jenkins" >> /etc/profile
echo "export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin" >> /etc/profile
 
/etc/profile
 
#sudo systemctl enable jenkins
#sudo systemctl restart jenkins
#开机启动
chkconfig jenkins on
service jenkins start
#查看日志
sudo tail -f /var/log/jenkins/jenkins.log
 
#Disable the firewall
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-all
 
#查看jenkins初始化密码
[root@dev ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
1
2
3
4
5
6
7
8
#Global Tool Configuration
#JDK
别名 jdk1.8.0_131
JAVA_HOME /usr/local/jdk1.8.0_131
 
#git
name: git version 1.8.3.1
Path to Git executable:  /usr/bin/git
1
2
#设置安全性
使用矩形安全策略
1
2
#配置完毕需要重启服务
systemctl restart jenkins




卸载jenkins

1
2
3
4
5
6
#卸载:如果要重装,或者本机不需要 Jenkins,可卸载:
sudo systemctl stop jenkins
sudo systemctl disable jenkins
sudo yum -y remove jenkins
sudo rm -rf /var/{lib,log,cache}/jenkins /usr/lib/jenkins /root/.jenkins
sudo rm -rf `sudo find /{etc,var,run} -name "jenkins*"`

实用插件

iOS专用:Xcode integration 

Android专用:Gradle plugin 

Gitlab插件:GitLab Plugin 和 Gitlab Hook Plugin 

Git插件: Git plugin 

GitBuckit插件: GitBuckit plugin 

签名证书管理插件: Credentials Plugin 和Keychains and Provisioning Profiles Management 

FTP插件: Publish over FTP 

脚本插件: Post-Build Script Plug-in 

修改Build名称/描述(二维码): build-name-setter / description setter plugin

获取仓库提交的commit log: Git Changelog Plugin 

自定义全局变量: Environment Injector Plugin 

自定义邮件插件: Email Extension Plugin 

获取当前登录用户信息: build-user-vars-plugin 

显示代码测试覆盖率报表: Cobertura Plugin 

来展示生成的单元测试报表,支持一切单测框架,如junit、nosetests等: Junit Plugin

其它: GIT plugin / SSH Credentials Plugin

插件:Publish Over SSH    ssh连接其他Linux机器

添加时间戳:Timestamper

输出样式: AnsiColor

自动配置语言: Locale plugin

前端nodejs: NodeJS Plugin

查看job配置历史:Job Configuration History Plugin

清理工作空间:Workspace Cleanup Plugin

   


1
2
3
4
5
6
#Jenkins安装目录和程序路径
#/etc/init.d/jenkins
#/etc/sysconfig/jenkins 
JENKINS_WAR="/usr/lib/jenkins/jenkins.war"
JENKINS_CONFIG=/etc/sysconfig/jenkins
JENKINS_PID_FILE="/var/run/jenkins.pid"
1
2
3
4
5
6
7
8
9
10
11
#添加密钥关联gitlab
mkdir /var/lib/jenkins/.ssh
#chown jenkins id_rsa.pub 
#chown jenkins id_rsa
[root@jenkins .ssh]# cat /var/lib/jenkins/.ssh/config 
# GitLab.com server
Host 139.159.xx.xx
RSAAuthentication yes
IdentityFile /var/lib/jenkins/.ssh/jenkins.rsa
sudo chown -R jenkins /var/lib/jenkins/.ssh/
git ls-remote -h git@github.com:adolfosrs/jenkins-test.git HEAD

参考:

https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions 

https://pkg.jenkins.io/redhat-stable/   rpm包下载地址

https://wiki.jenkins-ci.org/display/JENKINS/Offline+Jenkins+Installation 离线文档



本文转自 yanconggod 51CTO博客,原文链接:http://blog.51cto.com/yanconggod/1944143
上一篇:运维小知识---CentOS6.5安装Jenkins


下一篇:CentOS 7.4 安装配置Jenkins