>. bashrc closes CentOS7's own firewall service systemctldisablefirewalld&&systemctlstopfirewa"/> >. bashrc closes CentOS7's own firewall service systemctldisablefirewalld&&systemctlstopfirewa">
search
HomeComputer TutorialsComputer KnowledgeCentOS7 deploys cicd service in Jenkins

项目地址

https://www.jenkins.io/zh/

CentOS7 deploys cicd service in Jenkins

设置主机名:

hostnamectl set-hostname jenkins

不带时间的个性主机名

echo "PS1='[e[37;1m][[e[36;40m][e[32;40m]u[e[33;40m]@[e[31;40m]h [e[34;40m]w[e[37;1m]]\$[e[m]'" >>.bashrc

关闭CentOS7自带的防火墙服务

systemctl disable firewalld && systemctl stop firewalld

关闭SeLsinux

sed -i 's/enforcing/disabled/' /etc/selinux/config && setenforce 0

安装Git

yum install git -y

安装JDK

yum install -y java-1.8.0
yum install -y java-1.8.0-openjdk*

添加Jenkins源

最新版:
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat/jenkins.repo

稳定版本:
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

导入Jenkins密钥

最新版:
rpm --import http://pkg.jenkins.io/redhat/jenkins.io.key

稳定版本
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

ps:如果在以前从Jenkins导入过密钥,那么“rpm –import”将失败,因为在服务器上已经有了一个密钥。所以,这个错误信息可以忽略

安装Jenkins

### 安装当时最新稳定版
yum install -y jenkins

### rpm包安装指定版本,具体当前稳定版是哪个?https://www.jenkins.io/zh/download/
# redhat老版本
https://mirror.tuna.tsinghua.edu.cn/jenkins/redhat/
# redhat稳定版
https://mirror.tuna.tsinghua.edu.cn/jenkins/redhat-stable/

# 下载稳定版
wget https://mirror.tuna.tsinghua.edu.cn/jenkins/redhat-stable/jenkins-2.303.2-1.1.noarch.rpm

# 需要的依赖软件
yum install daemonize -y

# 开始安装
[root@jenkins ~]#rpm -ivh jenkins-2.303.2-1.1.noarch.rpm 
Preparing...################################# [100%]
Updating / installing...
 1:jenkins-2.303.2-1.1################################# [100%]

可选-挂载磁盘-设置Jenkins目录

格式化磁盘
mkfs.ext4 /dev/vdb 
创建data目录
mkdir /data/
挂载目录
mount /dev/vdb /data
设置开机自动挂载
echo "/dev/vdb /data ext4 defaults 0 0" >> /etc/fstab
创建Jenkins目录
mkdir /data/jenkins
设置Jenkins目录所属组所属用户
chown -R jenkins.jenkins /data/jenkins/

修改Jenkins的用户和端口号

ps:此处是因为Jenkins的端口号默认是8080,与tomcat的默认端口冲突
所以可以根据自己的条件判断是否需要修改,此处我是已经修改为9999端口
ps:此处是因为Jenkins的用户默认是jenkins,我们可以改为root用户来管理jenkins

vim /etc/sysconfig/jenkins

# 配置Jenkins的运行用户,这里不是登录用户
JENKINS_USER="root"

# 配置Jenkins的端口
JENKINS_PORT="8080"

# 配置Jenkins的目录
JENKINS_HOME="/data/jenkins"

# 配置资源限制
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Xms256m -Xmx512m -XX:MaxNewSize=256m"

设置开机自启

systemctl start jenkins && /sbin/chkconfig jenkins on && systemctl status jenkins

获取Jenkins密码

cat /var/lib/jenkins/secrets/initialAdminPassword

网页访问

打开xxx.xxx.xxx.xxx:8080

选择需要安装的插件

选择默认推荐即可,会安装通用的社区插件,剩下的可以在使用的时候再进行安装。

The above is the detailed content of CentOS7 deploys cicd service in Jenkins. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:每日运维. If there is any infringement, please contact admin@php.cn delete
Must-Know Fixes - Cannot Type Password on the Login ScreenMust-Know Fixes - Cannot Type Password on the Login ScreenApr 24, 2025 am 12:50 AM

Unable to type password at login screen Windows 7/8/10/11? Why does this issue occur? What should you do when you cannot type password on the login screen? This post from php.cn provides you with several feasible solutions to this matter.

[Solved] macOS Cannot Verify That This App Is Free from Malware - MiniTool[Solved] macOS Cannot Verify That This App Is Free from Malware - MiniToolApr 24, 2025 am 12:49 AM

Have you encountered the “macOS cannot verify that this app is free from malware” notification when running apps on Mac? This post from php.cn shows you how to solve this problem.

3 Targeted Solutions for Error Code 2000-0415 on Dell3 Targeted Solutions for Error Code 2000-0415 on DellApr 24, 2025 am 12:48 AM

Error code 2000-0415 is a small issue that is connected to some specific cables of your computer. It is pretty common in Dell devices. If you receive this error at the moment, the tips and tricks of this post on php.cn Website will be helpful to you.

Computer Freezes But Mouse Still Moves - Results-Driven MethodsComputer Freezes But Mouse Still Moves - Results-Driven MethodsApr 24, 2025 am 12:47 AM

Have you ever encountered a situation where the computer freezes but mouse still moves? Many people are troubled by this problem and they choose to forcefully shut down their computers. In fact, there are other methods that can help you solve this pr

Windows 7 Ultimate SP1 Free Download and Install (32/64 Bits) - MiniToolWindows 7 Ultimate SP1 Free Download and Install (32/64 Bits) - MiniToolApr 24, 2025 am 12:46 AM

Some users still use the Windows 7 edition and they want to download Windows 7 Ultimate SP1. However, they don’t know where to find the ISO file. Don’t worry! This post from php.cn tells you how to free download and install  Windows 7 Ultimate SP1.

Is Your Spectrum DVR Not Working? Try These Fixes! - MiniToolIs Your Spectrum DVR Not Working? Try These Fixes! - MiniToolApr 24, 2025 am 12:45 AM

What will you do if there is a conflict between your favourite TV shows and work appointments? Spectrum DVR can help you out! It allows you to record your favourite games or TV shows and watch them whenever you want. If you are plagued by Spectrum DV

How to Enable Selection Checkboxes in File Explorer Windows 10 - MiniToolHow to Enable Selection Checkboxes in File Explorer Windows 10 - MiniToolApr 24, 2025 am 12:44 AM

Do you have any idea how to show or remove checkboxes in File Explorer? If not, you’ve come to the right place. This paper on php.cn shows you a couple of feasible ways to enable selection checkboxes in File Explorer.

5 Fixes for VSS Error 0x800423F4 When Backup in Win10/115 Fixes for VSS Error 0x800423F4 When Backup in Win10/11Apr 24, 2025 am 12:43 AM

VSS error 0x800423F4 happens when creating a system image on Windows 11/10. If you are plagued by this annoying issue, follow the fixes collected by php.cn to root out it. Besides, professional Windows backup software like php.cn ShadowMaker is intro

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!