sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key sudo yum install jenkins安裝GIT
yum update yum -y install zlib-devel openssl-devel perl cpio expat-devel gettext-devel yum install curl-devel yum install autoconf wget http://git-core.googlecode.com/files/git-1.8.3.2.tar.gz tar xzvf git-1.8.3.2.tar.gz cd git-1.8.3.2 autoconf ./configure --with-curl=/opt/git make make install修改etc/passwd文件,讓jenkins用戶有ssh操作權限。
jenkins:x:496:496:Jenkins Continuous Integration Server:/var/lib/jenkins:/bin/bash使用jenkins用戶
su jenkins然後 生成ssh-key
ssh -keygen -t rsa -C "[email protected]"在浏覽器中輸入http://192.168.0.101:8080
新建項目
配置ssh key
Credentials--Global credentials (unrestricted)--Add Credentials
配置項目 Repository URL輸入Repository的Git地址(代碼地址)
填寫shell命令
ls -la //列出文件 rsync -auv --delete --exclude=/.git --exclude-from=./deployignore //rsync同步 刪除 過濾/.git 設置過濾文件 ./deployignore ./ [email protected]:/root/www/ // 用ssh登陸 目標服務器 ssh [email protected] ls -la /root/www/ //列出文件設置下更新目標的的服務器(也就是192.168.97.243),使他支持ssh
vim /etc/ssh/sshd_config RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys安裝rsync
yum -y install rsync
mkdir .ssh chmod 755 .ssh/
touch authorized_keys chmod 600 authorized_keys把jenkins的key保存在這個文件。