页面“Alpine”与“Jenkins进行持续集成”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
 
→‎NODE
 
第1行: 第1行:
  
  
=pre=
 
占用内存仅仅 37M ,非常的小巧。适合用在树莓派或者其他低内存设备上。
 
[https://liyin.date/2017/03/18/alpine-linux-setup/index.html Alpine Linux 折腾记]
 
=download =
 
  
==x86==
 
https://alpinelinux.org/downloads/
 
https://mirrors.aliyun.com/alpine/v3.10/releases/x86_64/alpine-standard-3.10.3-x86_64.iso
 
http://dl-cdn.alpinelinux.org/alpine/v3.10/releases/x86_64/alpine-standard-3.10.1-x86_64.iso
 
  
==Raspberry Pi==
+
仔细总结一下,我们会发现,除了编写代码,我们每天有相当一部分时间花在了编 译、运行单元测试、生成文档、打包和部署等烦琐且不起眼的工作上,这就是构建。如果我们现在还手工这样做,那成本也太高了,于是有人用软件的方法让这一系 列工作完全自动化,使得软件的构建可以像全自动流水线一样,只需要一条简单的命令,所有烦琐的步骤都能够自动完成,很快就能得到最终结果。
  
AArch64是ARMv8 架构的一种执行状态 so 下载这个  拿回来试一下
+
Maven真比自己的“规范化Ant”强大?其实他不知道自己只是在重新发明轮子,Maven已经有一大把现成的插件,全世界都在用,你自己不用写任何代码!
http://mirrors.ustc.edu.cn/alpine/v3.8/releases/aarch64/alpine-rpi-3.8.1-aarch64.tar.gz
 
  
http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/aarch64/alpine-rpi-3.8.1-aarch64.tar.gz
+
=现在一般更新在 站内资源 如下 [[基于Docker的Jenkins持续集成]]=
  
http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/armhf/alpine-rpi-3.8.1-armhf.tar.gz
+
[[基于Docker的Jenkins持续集成]]
  
国内的mirrors  有时比较同步比较慢
+
=常用CI/CD=
https://mirrors.alpinelinux.org/
+
最最流行的,也是使用最多的Jenkins
 +
有着持续集成DNA的ThoughtWorks GO。理念:"Deployment as pipeline" (华为容器平台应该是基于GO做的二次开发实现)
 +
Atlassian工具链之一的Bamboo
 +
与Gitlab紧密集成的Gitlab CI
 +
专为开源打造的Travis CI,与Github紧密集成
 +
使用Python语言实现的Buildbot,相信Pythoner看到会喜欢
  
===install on pi===
+
=安装=
[https://wiki.alpinelinux.org/wiki/Classic_install_or_sys_mode_on_Raspberry_Pi 要看 ]
+
== 通过docker-compose安装==
 +
[[基于Docker的Jenkins持续集成]]
  
https://wiki.alpinelinux.org/wiki/Raspberry_Pi
+
==已放弃普通安装已放弃的方法==
 +
ip 192.168.0.16
  
[https://wiki.alpinelinux.org/wiki/Create_a_Bootable_USB Create a Bootable USB]
+
<pre>
 +
已放弃
 +
docker pull  jenkins
 +
 +
[root@localhost ~]# docker images
 +
REPOSITORY          TAG                IMAGE ID            CREATED            SIZE
 +
jenkins            latest              cd14cecfdb3a        2 weeks ago        696MB
 +
 
 +
docker run --name=jenkins -it -u root -d -p 8080:8080 -p 50000:50000 -v /data/jenkins:/var/jenkins_home cd14cecfdb3a
 +
 
 +
--name=jenkins 命名 
 +
-it  交互模式运行
 +
-u root  root权限
 +
-d 后台运行
 +
-p 8080:8080 映射端口
 +
-p 50000:50000 映射端口
 +
-v /data/jenkins:/var/jenkins_home 映射目录
 +
3f08dc4f3f5d  本地镜像ID  docker images name 命令可查看ID eg #docker images jenkins
 +
 
 +
 
 +
#官方
 +
mkdir -p /data/jenkins-data
 +
docker run \
 +
  --name=jenkins \
 +
  -u root \
 +
  --rm \
 +
  -d \
 +
  -p 8080:8080 \
 +
  -p 50000:50000 \
 +
  -v /data/jenkins-data:/var/jenkins_home \
 +
  -v /var/run/docker.sock:/var/run/docker.sock \
 +
  jenkinsci/blueocean
 +
 
 +
 
 +
 
 +
#在运行docker容器时可以加如下参数来保证每次docker服务重启后容器也自动重启:
 +
$docker run --restart=always
 +
#如果已经启动了则可以使用如下命令:
 +
$docker update --restart=always <CONTAINER ID>
 +
 
 +
 
 +
 
 +
登入容器:
 +
docker exec -it jenkins /bin/bash
 +
 
 +
 
 +
 
 +
同步容器时间
 +
在Dockerfile中加入
 +
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && ntpdate cn.pool.ntp.org
 +
 +
容器运行后把容主机的/usr/share/zoneinfo/Asia/Shanghai 复制到容器的/etc/localtime
 +
 
 +
#先cp 到 /data/jenkins
 +
cp  /usr/share/zoneinfo/Asia/Shanghai  /data/jenkins
 +
 
 +
plubs
 +
Publish Over SSH
 +
 
 +
 +
Maven Integration
  
https://my.oschina.net/u/2306127/blog/1587585
+
Build
 +
clean install
 +
</pre>
  
https://wiki.alpinelinux.org/wiki/Create_a_Bootable_USB
 
  
[https://xts.so/linux/install-the-alpine-linux-on-raspberry-pi-zero-w.html 在树莓派Zero W上安装alpine linux系统]
+
[https://jenkins.io/zh/doc/book/installing/#docker 安装Jenkins zh]
  
=安装过程=
+
http://cn.jenkins.io/doc/book/installing/
  
输入root 没有密码 直接回车 如果是内网机器  记得打开 root login ssh
+
安装请见 [[Docker入门]]
  
 +
[http://www.cnblogs.com/stulzq/p/8627360.html  使用Docker安装Jenkins]
  
13-选择 sys 方式使用磁盘,将系统安装到本地硬盘-格式化硬盘-完成硬盘安装
+
[https://www.cnblogs.com/stulzq/p/9297260.html Jenkins 集群搭建]
sys
 
  
[https://blog.csdn.net/CSDN_duomaomao/article/details/76053229 Alpine linux硬盘安装]
+
=jenkins使用=
  
=configure=
 
 
<pre>
 
<pre>
国内源
+
要先安装maven 什么的
 +
 
 +
 
 +
Build
 +
Root POM pom.xml
 +
Goals and options clean install
 +
 
  
a. 编辑 /etc/apk/repositories
+
Post Steps
b. 将里面 dl-cdn.alpinelinux.org 的 改成 mirrors.aliyun.com ; 保存退出即可
+
Ex  shell
 +
cd /var/jenkins_home/workspace/doll-api-test/target
 +
scp doll-api-test.jar root@192.168.50.160:/data/update/boot/doll-api
  
cat  /etc/apk/repositories
 
#/media/cdrom/apks
 
http://mirrors.aliyun.com/alpine/v3.10/main
 
  
http://mirrors.aliyun.com/alpine/v3.10/community
+
sen build aritcle
#http://mirror.xtom.com.hk/alpine/v3.10/main
+
 
#http://mirror.xtom.com.hk/alpine/v3.10/community
+
ex  command  #记得要要全局那加ssh server
#http://mirror.xtom.com.hk/alpine/edge/main
 
#http://mirror.xtom.com.hk/alpine/edge/community
 
#http://mirror.xtom.com.hk/alpine/edge/testing
 
  
apk update
 
  
  
alpine:~# cat /etc/apk/repositories
 
#/media/cdrom/apks
 
http://mirrors.ustc.edu.cn/alpine/v3.8/main
 
http://mirrors.ustc.edu.cn/alpine/v3.8/community
 
cp /etc/apk/repositories /etc/apk/repositories.bak
 
 
</pre>
 
</pre>
  
=软件包管理工具apk的基本使用=
+
==gradle ==
 +
Gradle是一个基于Apache Ant和Apache Maven概念的项目自动化建构工具。它使用一种基于Groovy的特定领域语言来声明项目设置,而不是传统的XML。
 +
当前其支持的语言限于Java、Groovy和Scala,计划未来将支持更多的语言。
 +
 
 +
和maven同级,更简洁一些
 +
 
 +
 
 +
https://docs.gradle.org/current/userguide/userguide.html
 +
 
 +
==maven==
 
<pre>
 
<pre>
可以方便地安装、删除、更新软件。
 
  
#查询openssh相关的软件包
+
我试过 好像不用安装 jdk的呀  docker化的jenkins
  
apk search  openssh 
+
安装在configureTools 全局配置那里 要加上maven 和填写版本 以这个为目录名 例如下面的maven3.6.2
  
#安装一个软件包
 
  
apk add  xxx 
 
  
#删除已安装的xxx软件包
+
Build->Goals and options ->clean install -Pbeta -Dmaven.test.skip=true
 +
</pre>
  
apk del  xxx 
+
[https://blog.csdn.net/xlgen157387/article/details/68961371 Jenkins部署Maven多环境项目(dev、beta、prod)的参数设置]
  
#获取更多apk包管理的命令参数
+
[https://blog.csdn.net/u011781521/article/details/76696677 Jenkins系列(三)----Maven项目配置详解]
  
apk --help 
 
  
   
+
===maven 配置文件 ===
 +
<pre>maven 配置  可以在母机修改  注意  要先至少跑个工程后 才会安装maven 生成这个目录了
 +
 
 +
有时要密码的 ,格式要小心  烦死了
 +
 
 +
/data/docker/volumes/docker4jenkins_jenkins_home/_data/tools/hudson.tasks.Maven_MavenInstallation/maven/conf/settings.xml
 +
 
 +
/docker/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/jenkins-in-maven/conf下修改setting.xml文件。
 +
母机可能的目录
 +
/home/data/docker/volumes/docker4jenkins_jenkins_home/_data/tools/hudson.tasks.Maven_MavenInstallation/maven3.6.2/conf
 +
 
 +
 
 +
 
 +
位置 
 +
153    <mirror>
 +
154      <id>mirrorId</id>
 +
155      <mirrorOf>repositoryId</mirrorOf>
 +
156      <name>Human Readable Name for this Mirror.</name>
 +
157      <url>http://my.repository.com/repo/path</url>
 +
158    </mirror>
 +
159      -->
 +
160 <mirror>
 +
161      <id>nexus</id>
 +
162      <mirrorOf>*</mirrorOf>
 +
163      <url>http://192.168.4.189:8081/repository/maven-public/</url>
 +
164    </mirror>
 +
165  </mirrors>
  
#比如安装常用的网络相关工具:
 
  
#更新软件包索引文件
+
公用的方便安装的如下配置
 +
  <mirrors>
 +
    <!-- mirror
 +
    | Specifies a repository mirror site to use instead of a given repository. The repository that
 +
    | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
 +
    | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
 +
    |
 +
    <mirror>
 +
      <id>mirrorId</id>
 +
      <mirrorOf>repositoryId</mirrorOf>
 +
      <name>Human Readable Name for this Mirror.</name>
 +
      <url>http://my.repository.com/repo/path</url>
 +
    </mirror>
 +
    -->
 +
    <mirror>
 +
      <id>alimaven</id>
 +
      <name>aliyun maven</name>
 +
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
 +
      <mirrorOf>central</mirrorOf>       
 +
    </mirror>
 +
  </mirrors>
  
apk update   
 
  
#用于文本方式查看网页,用于测试http协议
 
  
apk add curl 
 
  
#提供了查看网络连接的协议端口的命令ss,可以替代netstat命令
+
#lx
 +
<servers>
 +
        <server>
 +
            <id>nexus</id>
 +
            <username>admin</username>
 +
            <password>lxtxadmin123</password>
 +
        </server>
 +
    </servers>
  
apk add iproute2 
+
    <mirrors>
 +
        <mirror>
 +
            <id>nexus</id>
 +
            <mirrorOf>*</mirrorOf>
 +
            <url>http://192.168.4.189:8081/repository/maven-public/</url>
 +
        </mirror>
 +
<!--        <mirror>-->
 +
<!--            <id>nexus-aliyun</id>-->
 +
<!--            <mirrorOf>central</mirrorOf>-->
 +
<!--            <name>Nexus aliyun</name>-->
 +
<!--            <url>http://maven.aliyun.com/nexus/content/groups/public</url>-->
 +
<!--        </mirror>-->
  
#drill 命令可以替代dig和nslookup DNS查询命令
+
    </mirrors>
  
apk add drill 
 
  
alpine:~# df -h
 
Filesystem                Size      Used Available Use% Mounted on
 
devtmpfs                10.0M        0    10.0M  0% /dev
 
shm                    245.0M        0    245.0M  0% /dev/shm
 
/dev/sda3                29.4G    576.7M    27.3G  2% /
 
tmpfs                    49.0M    108.0K    48.9M  0% /run
 
/dev/sda1                92.8M    19.1M    66.8M  22% /boot
 
 
</pre>
 
</pre>
=Alpine Linux 包管理=
+
[https://blog.csdn.net/w13511069150/article/details/93161141  Jenkins修改Maven配置]
 +
 
 +
[https://blog.csdn.net/xxsstf/article/details/84991931 Jenkins使用, maven插件配置修改]
 +
 
  
 +
[https://yq.aliyun.com/articles/752222 Maven国内可用下载速度快的仓库镜像(阿里Maven镜像地址)]
 +
 +
[https://www.cnblogs.com/xiao987334176/p/11433636.html Jenkins配置maven]
 +
 +
===snapshot快照仓库和release发布仓库===
 +
maven中的仓库分为两种,snapshot快照仓库和release发布仓库。snapshot快照仓库用于保存开发过程中的不稳定版 本,release正式仓库则是用来保存稳定的发行版本。定义一个组件/模块为快照版本,只需要在pom文件中在该模块的版本号后加上-SNAPSHOT即可(注意这里必须是大写)。release版本不允许修改,每次进行release版本修改,发布必须提升版本号。而snapshot一般是开发过程中的迭代版本,snapshot更新后,引用的项目可以不修改版本号自动下载构建。
 +
 +
[https://www.cnblogs.com/molao-doing/articles/6379216.html MAVEN snapshot快照和release发布库的区别、作用]
 +
 +
[https://www.cnblogs.com/EasonJim/p/6852840.html Maven快照机制(SNAPSHOT)]
 +
 +
[http://www.huangbowen.net/blog/2016/01/29/understand-official-version-and-snapshot-version-in-maven/ 理解Maven中的SNAPSHOT版本和正式版本]
 +
 +
==git  branch==
 +
这里应该 填写上操作过程 在我的geany上
 +
 +
[https://blog.csdn.net/jackyzheng/article/details/78750047 goodJenkins Git Parameter 插件配置过程]
 +
 +
[https://my.oschina.net/u/3493518/blog/1510531 Jenkins插件之——git Parameter插件]
 +
 +
 +
[https://blog.csdn.net/hwhua1986/article/details/53841741 Jenkins:使用Git Parameter插件实现tag或分支的选择性构建]
 +
 +
[https://blog.csdn.net/u012076316/article/details/52056107 jenkins构建时支持git选择分支]
 +
 +
[https://blog.csdn.net/qq_20641565/article/details/79132797 jenkins插件Git Parameter Plug-In分支构建项目]
 +
 +
[http://buxin-2008.iteye.com/blog/2357340 jenkins进行git多分支的docker镜像构建]
 +
 +
==android==
 +
[ https://blog.csdn.net/youshi520000/article/details/81027940 Android 使用 Jenkins 实现自动化打包【流程】&【踩坑]
 +
 +
 +
== Jenkins的初级应用(2)-Invoke Phing targets==
 +
[https://www.cnblogs.com/hodge01/p/9367498.html Jenkins的初级应用(2)-Invoke Phing targets]
 +
 +
==启动==
 +
===supervisor===
 
<pre>
 
<pre>
 +
#配合supervisor,把Jenkins直接变成一个服务。
 +
#可以在Linux上创建一个ci用户,然后,用supervisor启动并指定9090端口:
 +
# /etc/supervisor/conf.d/ci.conf
  
5.apk info
+
[program:ci]
$ apk info #列出所有已安装的软件包
+
command=java -jar /home/ci/jenkins.war --httpPort=9090
$ apk info -a zlib #显示完整的软件包信息
+
user=ci
$ apk info --who-owns /sbin/lbu #显示指定文件属于的包
+
autostart=true
 +
autorestart=true
 +
startsecs=30
 +
startretries=5
 
</pre>
 
</pre>
  
 +
=权限控制=
  
=on vps =
+
==Role-based Authorization Strategy==
my.vultr.com  ISO Library  has apline 3.8
 
也可以自己上传
 
  
[https://wiki.alpinelinux.org/wiki/Bootstrapping_Alpine_Linux Bootstrapping Alpine Linux - Alpine Linux]
+
可选插件-->Role-based Authorization Strategy
  
[https://discuss.vultr.com/discussion/1033/custom-iso-alpinelinux custom-iso-alpinelinux]
 
  
[https://www.linode.com/docs/tools-reference/custom-kernels-distros/install-alpine-linux-on-your-linode/ Install Alpine Linux on your Linode]
+
超级用户 root root
 +
other evan 
 +
group  ops java admin
  
=docker=
+
==基于项目(job)==
 
<pre>
 
<pre>
  cat  /etc/apk/repositories
+
Project roles 创建一个 dev 只配置所以 dev开头的内网项目
 +
 
 +
Role to add dev
 +
Pattern  dev.*  #配置
  
http://mirrors.aliyun.com/alpine/v3.10/main
+
选择【 Manage Roles】
http://mirrors.aliyun.com/alpine/v3.10/community
+
在【Global roles】创建一个新的全局角色 anyone,该角色不开放系统权限,只读.
  
 +
然后把你的号添加到 Global roles
  
apk add docker
+
Assign Roles-- Item roles 里面 加入你的号 并勾上 dev
  
rc-update add docker boot
 
  
service docker start
+
注意: Global roles 必要有 你要给别人用的用户名,不登录了什么 都没提示全局没有读权限 </pre>
 +
==lxtx eg==
 +
<pre>
 +
pre  倒好这里有个前端小哥 就叫 wusiyi
  
apk add py-pip
+
Manage Roles 角色管理 -- Global roles:  Role to add role name 为desk 全给read
apk add python-dev libffi-dev openssl-dev gcc libc-dev make
 
  
 +
Item roles :  role to add :Frontend_h5    Pattern: (?i)stage-.*|prod-hailuo-sdk-doc|bcb-blockchain-h5|k8s-local-nuxt-snsdev-hailuo-open-website 这个权限就看你给了
  
mkdir -p ~/.pip
 
  
#vim ~/.pip/pip.conf
+
cat >>~/.pip/pip.conf<<EOF
+
Assign Roles分配角色 Global roles: wusiyi 选择在 desk ; Item roles:Frontend_h5 和上面的 role to add 对应
[global]
+
 
index-url = http://mirrors.aliyun.com/pypi/simple/
+
</pre>
+
 
[install]
+
==权限see also==
trusted-host=mirrors.aliyun.com
+
 
EOF
+
[https://blog.csdn.net/Gred01/article/details/78587290 Jenkins教程四基于Role-based Authorization Strategy的用户权限管理]
 +
 
 +
[https://my.oschina.net/u/3413394/blog/1576357 enkins教程四 基于【Role-based Authorization Strategy】的用户权限管理]
 +
 
 +
[https://www.jianshu.com/p/7e148bcfb96e Jenkins使用教程之用户权限管理(包含插件的安装)]
 +
 
 +
[https://www.jianshu.com/p/6c274d9b22ad Jenkins自动化部署-权限管控篇 (六)]
 +
 
 +
=插件=
 +
 
 +
==dashboard 插件==
 +
dashboard 插件 [https://wiki.jenkins-ci.org/display/JENKINS/Dashboard+View Dashboard View]
 +
用来自定义自己的主页,例如对下列的 jenkins 的主页
  
pip install more-itertools==5.0.0 #3.10.3
+
== Wall display==
 +
用来将 jobs 的状态更加直观地显示在大屏幕上
  
pip install docker-compose
+
=== ssh server===
  
 +
====troubleshooting====
 +
<pre>
  
#err 
+
jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [win8r2]. Message [USERAUTH fail]]
 +
在jenkins 上使用publish over ssh ,报上述错误,
  
100% |████████████████████████████████| 81kB 1.2MB/s
+
ssh server
more-itertools requires Python '>=3.5' but the running Python is 2.7.16
+
1. 配置里面添加 jenkins pri key  2.远程被 jenkins 的远程那里添加jenkin的pub key 
  
 
</pre>
 
</pre>
==nodejs yarn etc==
+
https://ask.csdn.net/questions/379784
 +
 
 +
=NODE=
 +
jenkins plugin 要安装 node
 +
 
 +
alpine 里面也要安装 node.js  alpine
 +
https://wiki.linuxchina.net/index.php/Alpine#docker
 +
 
 +
 
 +
[https://blog.csdn.net/wanchaopeng/article/details/87934293 jenkins打包nodejs]
 +
 
 +
[https://www.cnblogs.com/vipzhou/p/7890016.html jenkins学习之自动打包构建nodejs应用]
 +
 
 +
=xk=
 
<pre>
 
<pre>
#换源 然后
+
dev 开发环境
apk add  --no-cache  nodejs yarn
+
beta 测试环境
 +
release 正式环境
 
</pre>
 
</pre>
  
https://wiki.alpinelinux.org/wiki/Docker
+
=DB =
 +
 
 +
[https://www.jianshu.com/p/e0c1fbc98f0d Jenkins自动化部署-数据库篇 (五)]
 +
 
 +
[https://stackoverrun.com/cn/q/11775565 需要在Jenkins管道脚本中执行SQL脚本的工作策略]
 +
 
 +
[https://www.zhihu.com/question/61737048 jenkins 进行持续集成的时候,关于SQL执行的问题]
 +
 
 +
[https://www.jianshu.com/p/e0c1fbc98f0d Jenkins自动化部署-数据库篇 (五)]
 +
 
 +
=磁盘处理=
 +
[[Jenkins服务器磁盘空间管理]]
  
 
=trouble shooting=
 
=trouble shooting=
==alpine镜像crontab无法运行问题 ==
+
== WeChat.java:[266,43] 找不到符号 ==
 +
<pre>
 +
[ERROR] /root/.jenkins/workspace/release_read/xtwl_service/src/main/java/org/platform_service/universal/pay/WeChat.java:[266,43] 找不到符号
 +
 
 +
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project xtwl_service: Compilation failure
 +
 
 +
原来是我用了 clean package -Prelease  之前还替换了配置文件  哈哈 </pre>
 +
 
 +
== offline ==
 +
点击Continue,大部分人都会出现这个界面,毕竟在天朝,我们先选择跳过
 +
 
 +
 
 +
==project lxtx-hello-admin-dao: Could not resolve dependencies for project com.lxtx.hello:lxtx ==
 
<pre>
 
<pre>
alpine镜像 普通用户 crontab无法运行问题
+
Waiting for Jenkins to finish collecting data
 +
[ERROR] Failed to execute goal on project lxtx-hello-admin-dao: Could not resolve dependencies for project com.lxtx.hello:lxtx-hello-admin-dao:jar:0.0.1: Could not find artifact com.lxtx.im:lxtx-admin-base-service:jar:0.1.6 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
 +
[ERROR]
 +
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
 +
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
 +
[ERROR]
 +
[ERROR] For more information about the errors and possible solutions, please read the following articles:
 +
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
 +
[ERROR]
 +
[ERROR] After correcting the problems, you can resume the build with the command
 +
[ERROR]  mvn <goals> -rf :lxtx-hello-admin-dao
 +
</pre>
 +
 
 +
=== soult===
 +
<pre>
 +
 
 +
docker dir
 +
/var/jenkins_home/.m2/settings.xml
 +
 
 +
母鸡目录
 +
/volumes/docker4jenkins_jenkins_home/_data/.m2/settings.xml
 +
 
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
 
 +
<!--
 +
Licensed to the Apache Software Foundation (ASF) under one
 +
or more contributor license agreements.  See the NOTICE file
 +
distributed with this work for additional information
 +
regarding copyright ownership.  The ASF licenses this file
 +
to you under the Apache License, Version 2.0 (the
 +
"License"); you may not use this file except in compliance
 +
with the License.  You may obtain a copy of the License at
 +
 
 +
    http://www.apache.org/licenses/LICENSE-2.0
 +
 
 +
Unless required by applicable law or agreed to in writing,
 +
software distributed under the License is distributed on an
 +
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +
KIND, either express or implied.  See the License for the
 +
specific language governing permissions and limitations
 +
under the License.
 +
-->
 +
 
 +
<!--
 +
| This is the configuration file for Maven. It can be specified at two levels:
 +
|
 +
|  1. User Level. This settings.xml file provides configuration for a single user,
 +
|                and is normally provided in ${user.home}/.m2/settings.xml.
 +
|
 +
|                NOTE: This location can be overridden with the CLI option:
 +
|
 +
|                -s /path/to/user/settings.xml
 +
|
 +
|  2. Global Level. This settings.xml file provides configuration for all Maven
 +
|                users on a machine (assuming they're all using the same Maven
 +
|                installation). It's normally provided in
 +
|                ${maven.home}/conf/settings.xml.
 +
|
 +
|                NOTE: This location can be overridden with the CLI option:
 +
|
 +
|                -gs /path/to/global/settings.xml
 +
|
 +
| The sections in this sample file are intended to give you a running start at
 +
| getting the most out of your Maven installation. Where appropriate, the default
 +
| values (values used when the setting is not specified) are provided.
 +
|
 +
|-->
 +
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
 +
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 +
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
 +
  <!-- localRepository
 +
  | The path to the local repository maven will use to store artifacts.
 +
  |
 +
  | Default: ${user.home}/.m2/repository
 +
    -->
 +
  <localRepository>D:\tools\apache-maven-3.3.9-bin\apache-maven-3.3.9\repository</localRepository>
 +
 
  
crond 服务用 root用户启动   or on ci  docker-compose exec -u  root  -T php-worker  sh -c "crond"
+
   <!-- interactiveMode
 +
  | This will determine whether maven prompts you when it needs input. If set to false,
 +
  | maven will use a sensible default value, perhaps based on some other setting, for
 +
  | the parameter in question.
 +
  |
 +
  | Default: true
 +
  <interactiveMode>true</interactiveMode>
 +
  -->
  
如果用官方提供alpine镜像是不自动启动crond的,得手动起
+
  <!-- offline
每个用户有单独的文件在/etc/crontabs文件夹
+
  | Determines whether maven should attempt to connect to the network when executing a build.
可以用supervisor启动crond,但要用root用户去启动crond,运行其他用户的定时任务
+
  | This will have an effect on artifact downloads, artifact deployment, and others.
 +
  |
 +
  | Default: false
 +
  <offline>false</offline>
 +
  -->
  
cron itself should run as root, regardless of which user you want to use to run the jobs.
+
  <!-- pluginGroups
 +
  | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
 +
  | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
 +
  | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
 +
  |-->
 +
  <pluginGroups>
 +
    <!-- pluginGroup
 +
    | Specifies a further group identifier to use for plugin lookup.
 +
    <pluginGroup>com.your.plugins</pluginGroup>
 +
    -->
 +
<pluginGroup>org.sonatype.plugins</pluginGroup>
 +
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
 +
  </pluginGroups>
  
This will install a crontab for user robuser. When cron executes jobs from this particular crontab, it will automatically switch users to robuser. However, cron can’t switch users like that if it’s not running as root, which is why you need to be running cron as root.
+
  <!-- proxies
 +
  | This is a list of proxies which can be used on this machine to connect to the network.
 +
  | Unless otherwise specified (by system property or command-line switch), the first proxy
 +
  | specification in this list marked as active will be used.
 +
  |-->
 +
  <proxies>
 +
    <!-- proxy
 +
    | Specification for one proxy, to be used in connecting to the network.
 +
    |
 +
    <proxy>
 +
      <id>optional</id>
 +
      <active>true</active>
 +
      <protocol>http</protocol>
 +
      <username>proxyuser</username>
 +
      <password>proxypass</password>
 +
      <host>proxy.host.net</host>
 +
      <port>80</port>
 +
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
 +
    </proxy>
 +
    -->
 +
  </proxies>
  
crontab  -l
+
  <!-- servers
crontab: must be suid to work properly
+
  | This is a list of authentication profiles, keyed by the server-id used within the system.
 +
  | Authentication profiles can be used whenever maven must make a connection to a remote server.
 +
  |-->
 +
  <servers>
 +
    <!-- server
 +
    | Specifies the authentication information to use when connecting to a particular server, identified by
 +
    | a unique name within the system (referred to by the 'id' attribute below).
 +
    |
 +
    | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
 +
    |      used together.
 +
    | -->
 +
    <server>
 +
      <id>nexus</id>
 +
      <username>admin</username>
 +
      <password>lxtxadmin123</password>
 +
    </server>
 +
 
  
apk add --update busybox-suid
+
    <!-- Another sample, using keys to authenticate.
 +
    <server>
 +
      <id>siteServer</id>
 +
      <privateKey>/path/to/private/key</privateKey>
 +
      <passphrase>optional; leave empty if not used.</passphrase>
 +
    </server>
 +
    -->
 +
  </servers>
  
 +
  <!-- mirrors
 +
  | This is a list of mirrors to be used in downloading artifacts from remote repositories.
 +
  |
 +
  | It works like this: a POM may declare a repository to use in resolving certain artifacts.
 +
  | However, this repository may have problems with heavy traffic at times, so people have mirrored
 +
  | it to several places.
 +
  |
 +
  | That repository definition will have a unique id, so we can create a mirror reference for that
 +
  | repository, to be used as an alternate download site. The mirror site will be the preferred
 +
  | server for that repository.
 +
  |-->
 +
  <mirrors>
 +
    <!-- mirror
 +
    | Specifies a repository mirror site to use instead of a given repository. The repository that
 +
    | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
 +
    | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
 +
    |
 +
    <mirror>
 +
      <id>mirrorId</id>
 +
      <mirrorOf>repositoryId</mirrorOf>
 +
      <name>Human Readable Name for this Mirror.</name>
 +
      <url>http://my.repository.com/repo/path</url>
 +
    </mirror>
 +
    -->
 +
<!--
 +
<mirror>
 +
        <id>nexus-aliyun</id>
 +
        <mirrorOf>central</mirrorOf>
 +
        <name>Nexus aliyun</name>
 +
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
 +
</mirror>
 +
 +
<mirror>
 +
        <id>nexus-aliyun</id>
 +
        <mirrorOf>central</mirrorOf>
 +
        <name>Nexus aliyun</name>
 +
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
 +
</mirror>-->
 +
 +
<mirror>
 +
      <id>nexus</id>
 +
      <mirrorOf>*</mirrorOf>
 +
      <url>http://192.168.4.189:8081/repository/maven-public/</url>
 +
    </mirror>
 +
<!--
 +
<mirror> 
 +
      <id>repo2</id> 
 +
      <mirrorOf>central</mirrorOf> 
 +
      <name>Human Readable Name for this Mirror.</name> 
 +
      <url>http://repo2.maven.org/maven2/</url> 
 +
    </mirror>  -->
 +
  </mirrors>
 +
 +
  <!-- profiles
 +
  | This is a list of profiles which can be activated in a variety of ways, and which can modify
 +
  | the build process. Profiles provided in the settings.xml are intended to provide local machine-
 +
  | specific paths and repository locations which allow the build to work in the local environment.
 +
  |
 +
  | For example, if you have an integration testing plugin - like cactus - that needs to know where
 +
  | your Tomcat instance is installed, you can provide a variable here such that the variable is
 +
  | dereferenced during the build process to configure the cactus plugin.
 +
  |
 +
  | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
 +
  | section of this document (settings.xml) - will be discussed later. Another way essentially
 +
  | relies on the detection of a system property, either matching a particular value for the property,
 +
  | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
 +
  | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
 +
  | Finally, the list of active profiles can be specified directly from the command line.
 +
  |
 +
  | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
 +
  |      repositories, plugin repositories, and free-form properties to be used as configuration
 +
  |      variables for plugins in the POM.
 +
  |
 +
  |-->
 +
  <profiles>
 +
    <!-- profile
 +
    | Specifies a set of introductions to the build process, to be activated using one or more of the
 +
    | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
 +
    | or the command line, profiles have to have an ID that is unique.
 +
    |
 +
    | An encouraged best practice for profile identification is to use a consistent naming convention
 +
    | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
 +
    | This will make it more intuitive to understand what the set of introduced profiles is attempting
 +
    | to accomplish, particularly when you only have a list of profile id's for debug.
 +
    |
 +
    | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
 +
    <profile>
 +
      <id>jdk-1.4</id>
 +
 +
      <activation>
 +
        <jdk>1.4</jdk>
 +
      </activation>
 +
 +
      <repositories>
 +
        <repository>
 +
          <id>jdk14</id>
 +
          <name>Repository for JDK 1.4 builds</name>
 +
          <url>http://www.myhost.com/maven/jdk14</url>
 +
          <layout>default</layout>
 +
          <snapshotPolicy>always</snapshotPolicy>
 +
        </repository>
 +
      </repositories>
 +
    </profile>
 +
    -->
 +
 +
    <!--
 +
    | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
 +
    | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
 +
    | might hypothetically look like:
 +
    |
 +
    | ...
 +
    | <plugin>
 +
    |  <groupId>org.myco.myplugins</groupId>
 +
    |  <artifactId>myplugin</artifactId>
 +
    |
 +
    |  <configuration>
 +
    |    <tomcatLocation>${tomcatPath}</tomcatLocation>
 +
    |  </configuration>
 +
    | </plugin>
 +
    | ...
 +
    |
 +
    | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
 +
    |      anything, you could just leave off the <value/> inside the activation-property.
 +
    |
 +
    <profile>
 +
      <id>env-dev</id>
 +
 +
      <activation>
 +
        <property>
 +
          <name>target-env</name>
 +
          <value>dev</value>
 +
        </property>
 +
      </activation>
 +
 +
      <properties>
 +
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
 +
      </properties>
 +
    </profile>
 +
    -->
 +
<profile>
 +
      <id>nexus</id>
 +
      <repositories>
 +
        <repository>
 +
          <id>central</id>
 +
          <url>http://central</url>
 +
          <releases><enabled>true</enabled></releases>
 +
          <snapshots><enabled>true</enabled></snapshots>
 +
        </repository>
 +
      </repositories>
 +
    <pluginRepositories>
 +
        <pluginRepository>
 +
          <id>central</id>
 +
          <url>http://central</url>
 +
          <releases><enabled>true</enabled></releases>
 +
          <snapshots><enabled>true</enabled></snapshots>
 +
        </pluginRepository>
 +
      </pluginRepositories>
 +
    </profile>
 +
  </profiles>
 +
 +
  <!-- activeProfiles
 +
  | List of profiles that are active for all builds.
 +
  |  -->
 +
  <activeProfiles>
 +
    <activeProfile>nexus</activeProfile>
 +
  </activeProfiles>
 +
 +
</settings>
 
</pre>
 
</pre>
  
[https://blog.csdn.net/gsying1474/article/details/68946455  alpine linux中如何使用crontab执行定时任务]
+
==[[Jenkins更多错误]]==
 +
 
 +
=进阶=
 +
[https://www.cnblogs.com/shenh/p/8963688.html jenkins + pipeline构建自动化部署]
 +
 
 +
 
 +
[https://blog.csdn.net/wh211212/article/details/77482138 Jenkins + Pipeline 构建流水线发布]
 +
 
 +
 
 +
[https://www.cnblogs.com/puresoul/p/4828913.html Jenkins内置环境变量的使用]
 +
 
 +
https://www.w3cschool.cn/jenkins/jenkins-5h3228n2.html
 +
 
 +
=参考=
 +
 
 +
[https://jenkins-zh.cn/ Jenkins 中文社区]
  
[https://stackoverflow.com/questions/36453787/failed-to-edit-crontab-linux-alpine Failed to edit crontab (linux Alpine)]
+
[https://www.cnblogs.com/along21/p/9724036.html Jenkins持续集成01—Jenkins服务搭建和部署]
  
[https://blog.csdn.net/weixin_43086579/article/details/84901497?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase Alpine容器启动Crontab任务]
+
[[Jenkins用户手册]]
  
 +
[https://jenkins.io/doc/book/installing/#docker Installing Docker]
  
 +
[https://blog.csdn.net/jackyzheng/article/category/6849960 jenkins docs ]
  
[https://devopsheaven.com/cron/docker/alpine/linux/2017/10/30/run-cron-docker-alpine.html Running cron jobs in a Docker Alpine container]
+
[http://www.cnblogs.com/dcba1112/archive/2011/05/01/2033805.html Maven的安装、配置及使用入门]
  
=ops=
+
[https://zh.wikipedia.org/wiki/Apache_Maven Apache Maven]
  
[[Alpine 修改docker的时区及安装telnet]]
+
[https://zh.wikipedia.org/wiki/Gradle Gradle是一个基于Apache Ant和Apache Maven概念的项目自动化建构工具]
  
<pre>
+
[https://www.jianshu.com/p/1eff16f60297 Maven 使用教程]
apk  add rsync
+
 
</pre>
+
[https://www.jianshu.com/p/60fb231a160e Jenkins学习之自动构建部署maven项目 have emailetc]
 +
 
 +
[https://www.liaoxuefeng.com/article/001463233913442cdb2d1bd1b1b42e3b0b29eb1ba736c5e000 使用Jenkins进行持续集成]
  
=desktop=
+
[http://blog.51cto.com/fluagen/40086 学习maven的使用,看到一篇很实用的入门教程(菜鸟级入门)]
暂时没有中文输入法
 
  
[https://www.cnblogs.com/jinzhenshui/p/8418281.html Alpine Linux:如何配置GUI的图形桌面环境:x Desktop Environment]
+
[http://blog.51cto.com/215687833/1916915 使用Jenkins 自动部署发布]
  
[https://blog.csdn.net/weixin_30590285/article/details/95415847 Alpine Linux:如何配置GUI的图形桌面环境:x Desktop Environment]
+
[https://www.cnblogs.com/yjmyzz/p/jenkins-tutorial-part-1.html jenkins 入门教程(上)]
  
[https://wiki.alpinelinux.org/wiki/MATE MATE 桌面]
+
[https://www.cnblogs.com/yjmyzz/p/jenkins-tutorial-part-2.html jenkins 入门教程(中)]
  
[https://wiki.alpinelinux.org/wiki/Awesome(wm)_Setup Awesome桌面]
+
[https://www.cnblogs.com/yjmyzz/p/jenkins-tutorial-part-3.html jenkins 入门教程()]
  
[https://liyin.date/2017/03/18/alpine-linux-setup/ 折腾记]
 
  
  
[https://icoolworld.github.io/alpine/alpine-%E4%B8%AD%E6%96%87%E6%88%AA%E5%9B%BE%E4%B9%B1%E7%A0%81%E9%97%AE%E9%A2%98.html alpine-中文截图乱码问题]
+
[https://blog.csdn.net/true100/article/details/47950215 Android项目利用jinkens自动打包]
  
=问题=
+
[http://blog.51cto.com/linuxg/1792086 Jenkins 持续集成平台构建之使用nexus搭建maven私有仓库]
Alpine Linux使用了musl,可能和其他Linux发行版使用的glibc实现会有所不同。在容器化中最可能遇到的是DNS问题,即musl实现的DNS服务不会使用resolv.conf文件中的search和domain两个配置,这对于一些通过DNS来进行服务发现的框架可能会遇到问题
 
  
[https://www.wencst.com/2017/11/23/docker-alpine%E7%89%88%E6%9C%AC%E6%9C%8D%E5%8A%A1%E4%B8%AD%E6%98%BE%E7%A4%BA%E4%B8%AD%E6%96%87/ docker alpine版本服务中显示中文]
+
[https://www.liaoxuefeng.com/article/001463233913442cdb2d1bd1b1b42e3b0b29eb1ba736c5e000 liaoxuefeng使用Jenkins进行持续集成]
  
=see also=
+
[https://blog.csdn.net/yelllowcong/article/details/78285230 Jenkins之配置Maven和JDK-yellowcong]
  
 +
[https://www.cnblogs.com/yangxia-test/p/4354328.html Jenkins学习二:Jenkins安装与配置]
  
 +
[https://blog.csdn.net/Gred01/article/details/78481606 基于Linux实现Jenkins+maven+git+tomcat的自动化构建部署项目]
  
[https://www.cnblogs.com/jackadam/p/9290366.html Alpine Linux常用命令]
+
[https://blog.csdn.net/gbenson/article/details/50970289 Linux平台搭建Jenkins+Maven+Shell实现自动化构建部署]
  
[https://blog.csdn.net/CSDN_duomaomao/article/details/76053229 Alpine linux硬盘安装]
+
==docker==
 +
[https://juejin.im/post/5994d93ef265da24843e416c Jenkins与Docker的持续集成实践]
  
[https://blog.csdn.net/CSDN_duomaomao/article/details/76152416 Alpine Linux 使用]
+
[https://www.cnblogs.com/xuezhigu/p/6690783.html 基于Docker构建带有Rsync的Jenkins]
  
[http://mirrors.ustc.edu.cn/help/alpine.html Alpine Linux 源使用帮助]
+
[https://www.cnblogs.com/soar1688/p/6833540.html Jenkins Docker安装及Docker build step插件部署配置]
  
[http://www.10tiao.com/html/357/201702/2247484888/1.html Alpine Linux配置使用技巧]
+
[https://www.kubernetes.org.cn/5230.html 原创:jenkins+github+docker+maven自动化构建部署]
  
[http://blog.csdn.net/csdn_duomaomao/article/details/76053229 Alpine linux硬盘安装]
+
== 权限==
 +
[https://blog.whsir.com/post-1785.html jenkins权限管理,不同用户显示不同项目]
  
[https://zh.wikipedia.org/wiki/BusyBox BusyBox]
+
[https://www.cnblogs.com/zz0412/p/jenkins_jj_14.html Jenkins进阶系列之——14配置Jenkins用户和权限]
  
 +
[https://www.jianshu.com/p/7e148bcfb96e Jenkins使用教程之用户权限管理(包含插件的安装)]
  
==Raspberry Pi==
+
[https://blog.csdn.net/itfootball/article/details/71404912 Jenkins用户权限管理]
[https://a-delacruz.github.io/alpine/alpine-linux.html Raspberry Pi 3 Alpine Linux arm64]
 
  
[https://wiki.alpinelinux.org/wiki/Raspberry_Pi Raspberry Pi]
+
==maven==
==other==
+
[https://blog.csdn.net/xlgen157387/article/details/68961371 Jenkins部署Maven多环境项目(dev、beta、prod)的参数设置]
[https://blog.csdn.net/diyiday/article/details/78332924 alpine linux填坑之路安装php-bcmath]
 
  
[https://blog.csdn.net/freewebsys/article/details/53816615 docker(13):alpinelinux安装jenkins]
+
[http://bookong.iteye.com/blog/2036633 通过Maven和Jenkins插件解决Java项目的配置管理]
  
[http://www.infoq.com/cn/news/2016/01/Alpine-Linux-5M-Docker Alpine Linux,一个只有5M的Docker镜像]
+
==优化==
 +
[http://softcook.logdown.com/posts/728344-method-for-reducing-the-jenkins-project-build-disk-space 减少jenkins项目构建磁盘空间的方法]
  
 +
[https://blog.csdn.net/ZZY1078689276/article/details/77531325 Jenkins丢弃旧的构建]
  
 +
[https://blog.csdn.net/qq_27791709/article/details/78835912 Jenkins-工作区清理插件]
  
[[category:ops]]
+
[[category:ops]]

2020年11月24日 (二) 07:41的版本



仔细总结一下,我们会发现,除了编写代码,我们每天有相当一部分时间花在了编 译、运行单元测试、生成文档、打包和部署等烦琐且不起眼的工作上,这就是构建。如果我们现在还手工这样做,那成本也太高了,于是有人用软件的方法让这一系 列工作完全自动化,使得软件的构建可以像全自动流水线一样,只需要一条简单的命令,所有烦琐的步骤都能够自动完成,很快就能得到最终结果。

Maven真比自己的“规范化Ant”强大?其实他不知道自己只是在重新发明轮子,Maven已经有一大把现成的插件,全世界都在用,你自己不用写任何代码!

现在一般更新在 站内资源 如下 基于Docker的Jenkins持续集成

基于Docker的Jenkins持续集成

常用CI/CD

最最流行的,也是使用最多的Jenkins 有着持续集成DNA的ThoughtWorks GO。理念:"Deployment as pipeline" (华为容器平台应该是基于GO做的二次开发实现) Atlassian工具链之一的Bamboo 与Gitlab紧密集成的Gitlab CI 专为开源打造的Travis CI,与Github紧密集成 使用Python语言实现的Buildbot,相信Pythoner看到会喜欢

安装

通过docker-compose安装

基于Docker的Jenkins持续集成

已放弃普通安装已放弃的方法

ip 192.168.0.16

已放弃
 docker pull  jenkins
 
[root@localhost ~]# docker images 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
jenkins             latest              cd14cecfdb3a        2 weeks ago         696MB

docker run --name=jenkins -it -u root -d -p 8080:8080 -p 50000:50000 -v /data/jenkins:/var/jenkins_home cd14cecfdb3a

--name=jenkins 命名  
-it  交互模式运行
-u root  root权限
-d 后台运行
-p 8080:8080 映射端口
-p 50000:50000 映射端口
-v /data/jenkins:/var/jenkins_home 映射目录
3f08dc4f3f5d  本地镜像ID  docker images name 命令可查看ID eg #docker images jenkins


#官方
mkdir -p /data/jenkins-data
docker run \
  --name=jenkins \
  -u root \
  --rm \
  -d \
  -p 8080:8080 \
  -p 50000:50000 \
  -v /data/jenkins-data:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
  jenkinsci/blueocean



#在运行docker容器时可以加如下参数来保证每次docker服务重启后容器也自动重启:
$docker run --restart=always
#如果已经启动了则可以使用如下命令:
$docker update --restart=always <CONTAINER ID>



登入容器:
docker exec -it jenkins /bin/bash



同步容器时间
在Dockerfile中加入
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && ntpdate cn.pool.ntp.org
或
容器运行后把容主机的/usr/share/zoneinfo/Asia/Shanghai 复制到容器的/etc/localtime

#先cp 到 /data/jenkins
cp  /usr/share/zoneinfo/Asia/Shanghai  /data/jenkins

plubs 
Publish Over SSH

	
Maven Integration

Build
clean install


安装Jenkins zh

http://cn.jenkins.io/doc/book/installing/

安装请见 Docker入门

使用Docker安装Jenkins

Jenkins 集群搭建

jenkins使用

要先安装maven 什么的


Build
Root POM	pom.xml
Goals and options clean install


Post Steps
Ex  shell
cd /var/jenkins_home/workspace/doll-api-test/target
scp doll-api-test.jar [email protected]:/data/update/boot/doll-api


sen build aritcle

ex  command  #记得要要全局那加ssh server



gradle

Gradle是一个基于Apache Ant和Apache Maven概念的项目自动化建构工具。它使用一种基于Groovy的特定领域语言来声明项目设置,而不是传统的XML。 当前其支持的语言限于Java、Groovy和Scala,计划未来将支持更多的语言。

和maven同级,更简洁一些


https://docs.gradle.org/current/userguide/userguide.html

maven


我试过 好像不用安装 jdk的呀  docker化的jenkins

安装在configureTools 全局配置那里 要加上maven 和填写版本 以这个为目录名 例如下面的maven3.6.2



 Build->Goals and options ->clean install -Pbeta -Dmaven.test.skip=true

Jenkins部署Maven多环境项目(dev、beta、prod)的参数设置

Jenkins系列(三)----Maven项目配置详解


maven 配置文件

maven 配置  可以在母机修改   注意  要先至少跑个工程后 才会安装maven 生成这个目录了

有时要密码的 ,格式要小心  烦死了

/data/docker/volumes/docker4jenkins_jenkins_home/_data/tools/hudson.tasks.Maven_MavenInstallation/maven/conf/settings.xml

/docker/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/jenkins-in-maven/conf下修改setting.xml文件。
母机可能的目录
/home/data/docker/volumes/docker4jenkins_jenkins_home/_data/tools/hudson.tasks.Maven_MavenInstallation/maven3.6.2/conf



位置  
153     <mirror>
154       <id>mirrorId</id>
155       <mirrorOf>repositoryId</mirrorOf>
156       <name>Human Readable Name for this Mirror.</name>
157       <url>http://my.repository.com/repo/path</url>
158     </mirror>
159      -->
160 <mirror>
161       <id>nexus</id>
162       <mirrorOf>*</mirrorOf>
163       <url>http://192.168.4.189:8081/repository/maven-public/</url>
164     </mirror>
165   </mirrors>


公用的方便安装的如下配置 
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>
  </mirrors>




#lx
<servers>
        <server>
            <id>nexus</id>
            <username>admin</username>
            <password>lxtxadmin123</password>
        </server>
    </servers>

    <mirrors>
        <mirror>
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://192.168.4.189:8081/repository/maven-public/</url>
        </mirror>
<!--        <mirror>-->
<!--            <id>nexus-aliyun</id>-->
<!--            <mirrorOf>central</mirrorOf>-->
<!--            <name>Nexus aliyun</name>-->
<!--            <url>http://maven.aliyun.com/nexus/content/groups/public</url>-->
<!--        </mirror>-->

    </mirrors>


Jenkins修改Maven配置

Jenkins使用, maven插件配置修改


Maven国内可用下载速度快的仓库镜像(阿里Maven镜像地址)

Jenkins配置maven

snapshot快照仓库和release发布仓库

maven中的仓库分为两种,snapshot快照仓库和release发布仓库。snapshot快照仓库用于保存开发过程中的不稳定版 本,release正式仓库则是用来保存稳定的发行版本。定义一个组件/模块为快照版本,只需要在pom文件中在该模块的版本号后加上-SNAPSHOT即可(注意这里必须是大写)。release版本不允许修改,每次进行release版本修改,发布必须提升版本号。而snapshot一般是开发过程中的迭代版本,snapshot更新后,引用的项目可以不修改版本号自动下载构建。

MAVEN snapshot快照和release发布库的区别、作用

Maven快照机制(SNAPSHOT)

理解Maven中的SNAPSHOT版本和正式版本

git branch

这里应该 填写上操作过程 在我的geany上

goodJenkins Git Parameter 插件配置过程

Jenkins插件之——git Parameter插件


Jenkins:使用Git Parameter插件实现tag或分支的选择性构建

jenkins构建时支持git选择分支

jenkins插件Git Parameter Plug-In分支构建项目

jenkins进行git多分支的docker镜像构建

android

[ https://blog.csdn.net/youshi520000/article/details/81027940 Android 使用 Jenkins 实现自动化打包【流程】&【踩坑]


Jenkins的初级应用(2)-Invoke Phing targets

Jenkins的初级应用(2)-Invoke Phing targets

启动

supervisor

#配合supervisor,把Jenkins直接变成一个服务。
#可以在Linux上创建一个ci用户,然后,用supervisor启动并指定9090端口:
# /etc/supervisor/conf.d/ci.conf

[program:ci]
command=java -jar /home/ci/jenkins.war --httpPort=9090
user=ci
autostart=true
autorestart=true
startsecs=30
startretries=5

权限控制

Role-based Authorization Strategy

可选插件-->Role-based Authorization Strategy


超级用户 root root other evan group ops java admin

基于项目(job)

Project roles 创建一个 dev 只配置所以 dev开头的内网项目 

Role to add  dev
Pattern  dev.*  #配置

选择【 Manage Roles】
在【Global roles】创建一个新的全局角色 anyone,该角色不开放系统权限,只读.

然后把你的号添加到 Global roles

Assign Roles-- Item roles 里面 加入你的号 并勾上 dev


注意: Global roles 必要有 你要给别人用的用户名,不登录了什么 都没提示全局没有读权限 

lxtx eg

pre  倒好这里有个前端小哥 就叫 wusiyi

Manage Roles 角色管理 -- Global roles:  Role to add  role name 为desk 全给read 

Item roles :   role to add :Frontend_h5     Pattern: (?i)stage-.*|prod-hailuo-sdk-doc|bcb-blockchain-h5|k8s-local-nuxt-snsdev-hailuo-open-website 这个权限就看你给了 


	
Assign Roles分配角色 Global roles: wusiyi 选择在 desk ; Item roles:Frontend_h5	和上面的 role to add  对应

权限see also

Jenkins教程四基于Role-based Authorization Strategy的用户权限管理

enkins教程四 基于【Role-based Authorization Strategy】的用户权限管理

Jenkins使用教程之用户权限管理(包含插件的安装)

Jenkins自动化部署-权限管控篇 (六)

插件

dashboard 插件

dashboard 插件 Dashboard View 用来自定义自己的主页,例如对下列的 jenkins 的主页

Wall display

用来将 jobs 的状态更加直观地显示在大屏幕上

ssh server

troubleshooting


jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [win8r2]. Message [USERAUTH fail]]
在jenkins 上使用publish over ssh ,报上述错误,

ssh server 
1. 配置里面添加 jenkins pri key   2.远程被 jenkins 的远程那里添加jenkin的pub key  

https://ask.csdn.net/questions/379784

NODE

jenkins plugin 要安装 node

alpine 里面也要安装 node.js alpine https://wiki.linuxchina.net/index.php/Alpine#docker


jenkins打包nodejs

jenkins学习之自动打包构建nodejs应用

xk

dev 开发环境
beta 测试环境
release 正式环境

DB

Jenkins自动化部署-数据库篇 (五)

需要在Jenkins管道脚本中执行SQL脚本的工作策略

jenkins 进行持续集成的时候,关于SQL执行的问题

Jenkins自动化部署-数据库篇 (五)

磁盘处理

Jenkins服务器磁盘空间管理

trouble shooting

WeChat.java:[266,43] 找不到符号

[ERROR] /root/.jenkins/workspace/release_read/xtwl_service/src/main/java/org/platform_service/universal/pay/WeChat.java:[266,43] 找不到符号

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project xtwl_service: Compilation failure

原来是我用了 clean package -Prelease  之前还替换了配置文件  哈哈 

offline

点击Continue,大部分人都会出现这个界面,毕竟在天朝,我们先选择跳过


project lxtx-hello-admin-dao: Could not resolve dependencies for project com.lxtx.hello:lxtx

Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal on project lxtx-hello-admin-dao: Could not resolve dependencies for project com.lxtx.hello:lxtx-hello-admin-dao:jar:0.0.1: Could not find artifact com.lxtx.im:lxtx-admin-base-service:jar:0.1.6 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :lxtx-hello-admin-dao

soult


docker dir
/var/jenkins_home/.m2/settings.xml

母鸡目录
/volumes/docker4jenkins_jenkins_home/_data/.m2/settings.xml

<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.home}/conf/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
     -->
  <localRepository>D:\tools\apache-maven-3.3.9-bin\apache-maven-3.3.9\repository</localRepository>


  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
	 <pluginGroup>org.sonatype.plugins</pluginGroup>
	 <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
  </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     | -->
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>lxtxadmin123</password>
    </server>
   

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
 <!--
 	<mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
	</mirror> 
 
	<mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
	</mirror>-->
 
	<mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://192.168.4.189:8081/repository/maven-public/</url>
    </mirror>
	 <!--
	<mirror>  
      <id>repo2</id>  
      <mirrorOf>central</mirrorOf>  
      <name>Human Readable Name for this Mirror.</name>  
      <url>http://repo2.maven.org/maven2/</url>  
    </mirror>  -->
  </mirrors>

  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->

    <!--
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
     | might hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
	<profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |  -->
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

</settings>

Jenkins更多错误

进阶

jenkins + pipeline构建自动化部署


Jenkins + Pipeline 构建流水线发布


Jenkins内置环境变量的使用

https://www.w3cschool.cn/jenkins/jenkins-5h3228n2.html

参考

Jenkins 中文社区

Jenkins持续集成01—Jenkins服务搭建和部署

Jenkins用户手册

Installing Docker

jenkins docs

Maven的安装、配置及使用入门

Apache Maven

Gradle是一个基于Apache Ant和Apache Maven概念的项目自动化建构工具

Maven 使用教程

Jenkins学习之自动构建部署maven项目 have emailetc

使用Jenkins进行持续集成

学习maven的使用,看到一篇很实用的入门教程(菜鸟级入门)

使用Jenkins 自动部署发布

jenkins 入门教程(上)

jenkins 入门教程(中)

jenkins 入门教程(下)


Android项目利用jinkens自动打包

Jenkins 持续集成平台构建之使用nexus搭建maven私有仓库

liaoxuefeng使用Jenkins进行持续集成

Jenkins之配置Maven和JDK-yellowcong

Jenkins学习二:Jenkins安装与配置

基于Linux实现Jenkins+maven+git+tomcat的自动化构建部署项目

Linux平台搭建Jenkins+Maven+Shell实现自动化构建部署

docker

Jenkins与Docker的持续集成实践

基于Docker构建带有Rsync的Jenkins

Jenkins Docker安装及Docker build step插件部署配置

原创:jenkins+github+docker+maven自动化构建部署

权限

jenkins权限管理,不同用户显示不同项目

Jenkins进阶系列之——14配置Jenkins用户和权限

Jenkins使用教程之用户权限管理(包含插件的安装)

Jenkins用户权限管理

maven

Jenkins部署Maven多环境项目(dev、beta、prod)的参数设置

通过Maven和Jenkins插件解决Java项目的配置管理

优化

减少jenkins项目构建磁盘空间的方法

Jenkins丢弃旧的构建

Jenkins-工作区清理插件