http://t.csdn.cn/MnI4b
#卸载python3
rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps
#删除所有残余文件
whereis python3 |xargs rm -frv
#查看现有安装的python,验证是否删除干净
whereis python3
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel gcc
下载链接:https://www.python.org/downloads/release/python-373/
cd /usr/local
wget https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tgz
tar -zxvf Python-3.8.6.tgz
mkdir -p /usr/local/python3
chmod 777 /usr/local/python3
cd Python-3.8.6
./configure --prefix=/usr/local/python3
make && make install
添加python软链接
ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
添加pip3软链接
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
python3 -V
pip3 --help
pip3 -V
pip3 install --upgrade setuptools -i https://pypi.doubanio.com/simple/
pip3 install virtualenv -i https://pypi.doubanio.com/simple/
pip3 install virtualenvwrapper -i https://pypi.doubanio.com/simple/ # 命令优化工具包
# 如安装失败升级pip pip install pip --upgrade pip -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
find / -name virtualenv
ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv
virtualenv
vim /usr/local/python3/bin/virtualenvwrapper.sh
vi ~/.bashrc
export WORKON_HOME=~/.virtualenvs
source /usr/local/python3/bin/virtualenvwrapper.sh
source ~/.bashrc
mkvirtualenv 虚拟环境名称 # python2写法
kvirtualenv -p python3 虚拟环境名称 # python3写法
workon # 查看当前虚拟环境
workon 虚拟环境名称 # 进入虚拟环境
deactivate # 退出当前虚拟环境
python3 -m pip install --upgrade pip
pip3 install -r requests.txt -i https://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple
pytest -v -s test_pytest[::类名[::函数名]]
yum install java-1.8.0-openjdk* -y
which java
ls -lrt /usr/bin/java
ls -lrt /etc/alternatives/java
# java路径:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-1.el7.x86_64/jre/bin/java
1)获取jenkins安装包
下载链接:https://www.jenkins.io/zh/download/
2) 把安装包上传到192.168.66.101服务器,进行安装
rpm -ivh jenkins-2.190.3-1.1.noarch.rpm
JENKINS_USER="root"
JENKINS_PORT="8090"
4)把端口添加防火墙或关闭防火墙(二选1)
firewall-cmd --zone=public --add-port=82/tcp --permanent
firewall-cmd --reload
systemctl stop firewalld.service
systemctl disable firewalld.service
5)添加jdk安装路径
vi /etc/init.d/jenkins
添加如下内容
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-1.el7.x86_64/jre/bin/java
4)重新加载配置文件并启动Jenkins
systemctl daemon-reload # 命令重新加载配置文件
systemctl start jenkins # 命令启动Jenkins
systemctl status jenkins.service # 命令查看Jenkins服务的状态
ifconfig
http://192.168.132.30:8090
cat /var/lib/jenkins/secrets/initialAdminPassword
7)跳过插件安装
因为Jenkins插件需要连接默认官网下载,速度非常慢,而且经过会失败,所以我们暂时先跳过插件安
装
8)添加一个管理员账户,并进入Jenkins后台
rpm -ql jenkins # 查看jenkins所有目录
cd /usr/share/java/
mkdir /var/lib/jenkins/temp
mv jenkins.war /var/lib/jenkins/temp/
wget http://mirrors.tuna.tsinghua.edu.cn/jenkins/war/2.349/jenkins.war # 根据提示下载相应版本war包
/etc/init.d/jenkins restart # 重启jenkins
# 报/usr/share/java/jenkins.war not installed,需要将war报移动到/usr/share/java/下
mv jenkins.war /usr/share/java
/etc/init.d/jenkins restart
systemctl restart jenkins # 系统重启jenkins
有的版本是https://updates.jenkins.io/download有的是https://updates.jenkins-ci.org/download,根据情况修改
vim hudson.model.UpdateCenter.xml
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
sed -i 's/https:\/\/updates.jenkins.io\/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
Role-based Authorization Strategy
插件来管理Jenkins用户权限Manage and Assign Roles
,点击"Manage Roles"Global roles(全局角色)
:管理员等高级用户可以创建基于全局的角色 Project roles(项目角色)
:针对某个或者某些项目的角色Slave roles(奴隶角色)
:节点相关的权限 baseRole
:该角色为全局角色。这个角色需要绑定Overall下面的Read权限,是为了给所有用户绑dev_role
:该角色为项目角色。使用正则表达式绑定"dev.*",意思是只能操作itcast开头的项目。test_role01
:该角色也为项目角色。绑定"test.*",意思是只能操作itheima开头的项目zhagnsan
用户分别绑定baseRole和role1角色lisi
用户分别绑定baseRole和role2角色1. 安装Credentials Binding
插件
yum info git
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker
yum remove git
wget https://github.com/git/git/archive/v2.9.2.tar.gz
tar -xzvf v2.9.2.tar.gz
cd git-2.9.2
make prefix=/usr/local/git all
make prefix=/usr/local/git install
vim /etc/profile
export PATH="/usr/local/git/bin:$PATH"
source /etc/profile
git --version
3. ssh密钥类型
git config --global user.name 'JSonliuJ'
git config --global user.email "[email protected]"
kdir ~/.ssh
chmod 700 ~/.ssh
git --help
ssh-keygen -t rsa -C "邮件地址"
git init
git init --bare git_project # 初始化一个空目录
cd git_project
git clone 远程仓库地址
touch test02.sh
git add test02.sh
git commit -m '注释'
git push # 远程仓库
git rm test02.sh
git commit -m "说明"
git push
Jenkins内置4种构建触发器
构建url:http://127.0.0.1:8081/job/api_%E8%BF%9C%E7%A8%8B%E6%9E%84%E5%BB%BA%E8%A7%A6%E5%8F%91%E5%99%A8/build?token=6666
每30分钟构建一次:H代表形参 H/30 * * * *
每2个小时构建一次: H H/2 * * *
每天的8点,12点,22点,一天构建3次: (多个时间点中间用逗号隔开) 0 8,12,22 * * *
每天中午12点定时构建一次 H 12 * * *
每天下午18点定时构建一次 H 18 * * *
在每个小时的前半个小时内的每10分钟 H(0-29)/10 * * * *
每两小时一次,每个工作日上午9点到下午5点(也许是上午10:38,下午12:38,下午2:38,下午4:38) H H(9-16)/2 * * 1-5
1. 开启webhook功能
2. 在项目添加webhook