持续集成的目的:
让我们每次更新了代码提交到 git 仓库后就自动运行构建新版本,自动部署
到测试环境,从而提高生产效率,告别重复的劳动
系统环境:CentOS6.5 、JDK SE 1.8.0_60 、Maven3.0.5、Jenkins2.4.1、Git(yum安装)、Docker、docker-compose、gitlab
maven、jdk、git、安装其他文章写过,再次略过。
git安装:
yum -y install git
gitlab安装:
1.如想使用Postfix来发送邮件,在安装期间请选择‘Internet Site‘. 您也可以用sendmai或者 配置SMTP服务 并 使用SMTP发送邮件.
在 Centos 6 和 7 系统上, 下面的命令将在系统防火墙里面开放HTTP和SSH端口.
[[email protected] src]# yum install curl openssh-server openssh-clients postfix cronie [[email protected] src]# service postfix start [[email protected] src]# chkconfig postfix on [[email protected] src]# lokkit -s http -s ssh
2. 添加GitLab仓库,并安装到服务器上
curl -sS http://packages.gitlab.cc/install/gitlab-ce/script.rpm.sh | sudo bash sudo yum install gitlab-ce
3. 启动gitlab
gitlab-ctl reconfigure
docker安装:
- 安装docker的源
wget yum ivh epel-release-latest-6.noarch.rpm rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm yum install docker-io
2.安装docker-compose
curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
安装jenkins:
wget -O /etc/yum.repos.d/jenkins.repo rpm --import yum install jenkins
配置jenkins的端口等:
sed -i ‘s#JENKINS_JAVA_CMD=""#JENKINS_JAVA_CMD="/usr/local/java/jdk/bin/java"#g‘ /etc/sysconfig/jenkins sed -i ‘s/JENKINS_PORT="8080"/JENKINS_PORT="8009"/g‘ /etc/sysconfig/jenkins sed -i ‘s/JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"/JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Duser.timezone=Asia/Shanghai"/g‘ /etc/sysconfig/jenkins
启动jenkins:
/etc/init.d/jenkins start
浏览器访问:
第一次访问会提示输入密码,密码文件在:
cat /var/lib/jenkins/secrets/initialAdminPassword
时间: 2024-11-05 12:17:50