docker安装jenkins

运行jenkins

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文件里。
docker安装jenkins_第1张图片

安装 maven + git

升级apt

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

apt install git
apt install maven

push触发编译、单元测试、发布

docker安装jenkins_第2张图片

配置git仓库地址
docker安装jenkins_第3张图片

配置分支信息,默认是*/master,这里改成目标分支 */main
docker安装jenkins_第4张图片
绑定项目的pom.xml
docker安装jenkins_第5张图片
maven绑定国内镜像源
docker安装jenkins_第6张图片
添加国内镜像源
docker安装jenkins_第7张图片

<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

docker安装jenkins_第8张图片

你可能感兴趣的:(docker,jenkins,容器)