运行jenkins
bash
docker run -d \
--name jenkins \
--hostname jenkins \
-u root \
-p 29090:8080 \
--restart always \
-v D:\springcloud\学习\jekins\jenkins\jks_home:/var/jenkins_home \
jenkins/jenkins
获取root登录密码
密码在jekins_home/secrets/initalAdminPassword文件里。
安装 maven + git
升级apt
bash
echo " #添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
#中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
#163源
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
#清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
" > /etc/apt/sources.list
apt update
安装git、maven
bash
apt install git
apt install maven
push触发编译、单元测试、发布
配置git仓库地址
配置分支信息,默认是*/master,这里改成目标分支 */main
绑定项目的pom.xml
maven绑定国内镜像源
添加国内镜像源
bash
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
自动push jar包到测试服务器
安装插件 PUSH OVSER SSH
安装测试服务器
bash
docker run -d --name test-server \
--hostname test-server \
-p 2222:22 -p 9090:8090 \
eclipse/centos_jdk8
9090: 暴露给浏览器;2222:暴露给jekins ssh连接test-server所用
bash
#安装ssh服务端
sudo yum install openssh-server.x86_64 -y
#
jenkins添加测试服务器