Skip to content

Commit abb4c0c

Browse files
committed
jenkins
1 parent f7faa0f commit abb4c0c

87 files changed

Lines changed: 1114 additions & 573 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

project/Jenkinsfile.html

Lines changed: 227 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@
4747
</div>
4848
<div class="section"><div class="titlepage"><div><div><h5 class="title"><a id="agent.docker"></a>6.3.1.1.2. docker</h5></div></div></div>
4949

50+
<p><a class="ulink" href="https://jenkins.io/doc/book/pipeline/docker/" target="_top">https://jenkins.io/doc/book/pipeline/docker/</a></p>
51+
<p>添加 jenkins 用户到 docker 组</p>
52+
<pre class="screen">
53+
54+
[root@localhost ~]# gpasswd -a jenkins docker
55+
Adding user jenkins to group docker
56+
57+
[root@localhost ~]# cat /etc/group | grep ^docker
58+
docker:x:993:jenkins
59+
60+
</pre>
61+
5062
<pre class="screen">
5163

5264
pipeline {
@@ -72,9 +84,22 @@
7284
}
7385
}
7486
}
75-
}
87+
}
88+
89+
pipeline {
90+
agent {
91+
docker { image 'php:latest' }
92+
}
93+
stages {
94+
stage('Test') {
95+
steps {
96+
sh 'php --version'
97+
}
98+
}
99+
}
100+
}
76101

77-
</pre>
102+
</pre>
78103
</div>
79104
</div>
80105
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="pipeline.stages"></a>6.3.1.2. stages</h4></div></div></div>
@@ -107,9 +132,9 @@
107132
</div>
108133

109134

110-
111135

112-
136+
137+
113138

114139

115140

@@ -176,12 +201,12 @@
176201
}
177202

178203
</pre>
179-
</div>
204+
</div>
205+
206+
180207

181208

182-
183209

184-
185210

186211
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="pipeline.environment"></a>6.3.1.5. 设置环境变量</h4></div></div></div>
187212

@@ -260,8 +285,8 @@
260285

261286
</pre>
262287
</div>
263-
264-
288+
289+
265290
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="pipeline.options"></a>6.3.1.7. options</h4></div></div></div>
266291

267292
<p>还能定义一些管道特定的选项,介绍几个常用的:</p>
@@ -273,7 +298,7 @@
273298
timestamps - 控制台输出前面加时间戳options { timestamps() }
274299

275300
</pre>
276-
</div>
301+
</div>
277302
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="pipeline.triggers"></a>6.3.1.8. triggers</h4></div></div></div>
278303

279304
<p>触发器指令定义了这个管道何时该执行,就可以定义两种cron和pollSCM</p>
@@ -1095,7 +1120,7 @@
10951120
}
10961121

10971122
</pre>
1098-
1123+
10991124
<pre class="screen">
11001125

11011126

@@ -1214,13 +1239,13 @@
12141239

12151240
</pre>
12161241
</div>
1217-
1218-
1219-
1242+
1243+
1244+
12201245
</div>
12211246
<div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="pipeline.scm"></a>6.3.4. 版本控制</h3></div></div></div>
12221247

1223-
1248+
12241249
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="steps.checkout"></a>6.3.4.1. checkout</h4></div></div></div>
12251250

12261251
<p>https://github.com/jenkinsci/workflow-scm-step-plugin/blob/master/README.md</p>
@@ -1326,7 +1351,7 @@
13261351
</div>
13271352
<div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="pipeline.workspace"></a>6.3.6. 工作区</h3></div></div></div>
13281353

1329-
1354+
13301355
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="pipeline.dir"></a>6.3.6.1. 变更目录</h4></div></div></div>
13311356

13321357
<pre class="screen">
@@ -1390,7 +1415,7 @@
13901415

13911416
</pre>
13921417
</div>
1393-
1418+
13941419
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="steps.cleanWs"></a>6.3.6.4. 清理工作区</h4></div></div></div>
13951420

13961421
<pre class="screen">
@@ -1439,12 +1464,194 @@
14391464
}
14401465

14411466
</pre>
1442-
1467+
14431468
</div>
1469+
1470+
1471+
</div>
1472+
<div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="Jenkinsfile.example"></a>6.3.7. Jenkinsfile Pipeline Example ()</h3></div></div></div>
14441473

1445-
1474+
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="idp31"></a>6.3.7.1. Maven 子模块范例</h4></div></div></div>
1475+
1476+
<p>
1477+
Maven 子模块创建方法
1478+
<a class="ulink" href="https://www.netkiller.cn/java/build/maven.html#maven.module" target="_top">https://www.netkiller.cn/java/build/maven.html#maven.module</a>
1479+
</p>
1480+
<p>目录结构</p>
1481+
<pre class="screen">
1482+
1483+
Project
1484+
|
1485+
|--- common (Shared)
1486+
| | ---pom.xml
1487+
|--- project1 (depend common)
1488+
| |--- pom.xml
1489+
|--- project2 (depend common)
1490+
| |--- pom.xml
1491+
|---pom.xml
1492+
1493+
1494+
</pre>
1495+
<p>构建 父项目</p>
1496+
<pre class="screen">
1497+
1498+
pipeline {
1499+
agent {
1500+
label "default"
1501+
}
1502+
stages {
1503+
1504+
stage("检出") {
1505+
steps {
1506+
checkout(
1507+
[$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]],
1508+
userRemoteConfigs: [[url: env.GIT_REPO_URL]]]
1509+
)
1510+
}
1511+
}
1512+
1513+
stage("构建") {
1514+
steps {
1515+
echo "构建中..."
1516+
sh 'mvn package -Dmaven.test.skip=true' // mvn 示例
1517+
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true // 收集构建产物
1518+
echo "构建完成."
1519+
}
1520+
}
1521+
1522+
stage("测试") {
1523+
steps {
1524+
echo "单元测试中..."
1525+
// 请在这里放置您项目代码的单元测试调用过程,例如:
1526+
sh 'mvn test' // mvn 示例
1527+
echo "单元测试完成."
1528+
junit '**/target/surefire-reports/*.xml' // 收集单元测试报告的调用过程
1529+
}
1530+
}
1531+
1532+
stage("部署") {
1533+
steps {
1534+
echo "部署中..."
1535+
echo "部署完成"
1536+
}
1537+
}
1538+
}
1539+
}
1540+
1541+
</pre>
1542+
<p>构建共享项目</p>
1543+
<pre class="screen">
1544+
1545+
pipeline {
1546+
agent {
1547+
label "default"
1548+
}
1549+
stages {
1550+
1551+
stage("检出") {
1552+
steps {
1553+
checkout(
1554+
[$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]],
1555+
userRemoteConfigs: [[url: env.GIT_REPO_URL]]]
1556+
)
1557+
}
1558+
}
1559+
1560+
stage("构建") {
1561+
steps {
1562+
echo "构建中..."
1563+
dir(path: 'common') {
1564+
sh 'mvn package -Dmaven.test.skip=true' // mvn 示例
1565+
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true // 收集构建产物
1566+
}
1567+
echo "构建完成."
1568+
}
1569+
}
1570+
1571+
stage("测试") {
1572+
steps {
1573+
echo "单元测试中..."
1574+
sh 'mvn test' // mvn 示例
1575+
echo "单元测试完成."
1576+
junit 'target/surefire-reports/*.xml' // 收集单元测试报告的调用过程
1577+
}
1578+
}
1579+
1580+
stage("部署") {
1581+
steps {
1582+
echo "部署中..."
1583+
dir(path: 'common') {
1584+
sh 'mvn install'
1585+
}
1586+
echo "部署完成"
1587+
}
1588+
}
1589+
}
1590+
}
1591+
1592+
</pre>
1593+
<p>构建 project1 和 project2</p>
1594+
<pre class="screen">
1595+
1596+
pipeline {
1597+
agent {
1598+
label "default"
1599+
}
1600+
stages {
1601+
1602+
stage("检出") {
1603+
steps {
1604+
checkout(
1605+
[$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]],
1606+
userRemoteConfigs: [[url: env.GIT_REPO_URL]]]
1607+
)
1608+
}
1609+
}
1610+
stage("共享库") {
1611+
steps {
1612+
echo "构建中..."
1613+
dir(path: 'common') {
1614+
sh 'mvn install -Dmaven.test.skip=true' // mvn 示例
1615+
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true // 收集构建产物
1616+
}
1617+
echo "构建完成."
1618+
}
1619+
}
1620+
stage("构建") {
1621+
steps {
1622+
echo "构建中..."
1623+
dir(path: 'project1') {
1624+
sh 'mvn package -Dmaven.test.skip=true' // mvn 示例
1625+
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true // 收集构建产物
1626+
}
1627+
echo "构建完成."
1628+
1629+
}
1630+
}
1631+
1632+
stage("测试") {
1633+
steps {
1634+
echo "单元测试中..."
1635+
sh 'mvn test' // mvn 示例
1636+
echo "单元测试完成."
1637+
junit 'target/surefire-reports/*.xml' // 收集单元测试报告的调用过程
1638+
}
1639+
}
1640+
1641+
stage("部署") {
1642+
steps {
1643+
echo "部署中..."
1644+
// 部署脚本
1645+
echo "部署完成"
1646+
}
1647+
}
1648+
}
1649+
}
1650+
1651+
</pre>
1652+
</div>
1653+
14461654
</div>
1447-
14481655
</div><div xmlns="" id="disqus_thread"></div><script xmlns="">
14491656

14501657
var disqus_config = function () {

project/contacts.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@
2323
<p>OSChina: <a class="ulink" href="http://my.oschina.net/neochen/" target="_top">http://my.oschina.net/neochen/</a></p>
2424
<p>Facebook: <a class="ulink" href="https://www.facebook.com/bg7nyt" target="_top">https://www.facebook.com/bg7nyt</a></p>
2525
<p>Flickr: <a class="ulink" href="http://www.flickr.com/photos/bg7nyt/" target="_top">http://www.flickr.com/photos/bg7nyt/</a></p>
26-
<p>Twitter: <a class="ulink" href="http://twitter.com/bg7nyt" target="_top">http://twitter.com/bg7nyt</a></p>
27-
<p>Digg: <a class="ulink" href="http://www.digg.com/netkiller" target="_top">http://www.digg.com/netkiller</a></p>
26+
2827
<p>Disqus: <a class="ulink" href="http://disqus.com/netkiller/" target="_top">http://disqus.com/netkiller/</a></p>
2928
<p>solidot: <a class="ulink" href="http://solidot.org/~netkiller/" target="_top">http://solidot.org/~netkiller/</a></p>
29+
30+
<p>Reddit: <a class="ulink" href="https://www.reddit.com/user/netkiller/" target="_top">https://www.reddit.com/user/netkiller/</a></p>
31+
<p>Digg: <a class="ulink" href="http://www.digg.com/netkiller" target="_top">http://www.digg.com/netkiller</a></p>
32+
<p>Twitter: <a class="ulink" href="http://twitter.com/bg7nyt" target="_top">http://twitter.com/bg7nyt</a></p>
33+
3034
<p>weibo: <a class="ulink" href="http://weibo.com/bg7nyt" target="_top">http://weibo.com/bg7nyt</a></p>
3135
</div>
3236
<p></p>

project/gitlab/branch.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<p>testing:保护 </p>
3232
<p>development:保护 </p>
3333

34-
<div class="procedure"><a id="idp62"></a><p class="title"><strong>过程 2.4. Gitlab 分支应用 - 创建分支</strong></p><ol class="procedure" type="1"><li class="step">
34+
<div class="procedure"><a id="idp63"></a><p class="title"><strong>过程 2.4. Gitlab 分支应用 - 创建分支</strong></p><ol class="procedure" type="1"><li class="step">
3535
<p>首先,点击左侧 Commits 按钮,然后点击 Branches 按钮进入分支管理</p>
3636
<div><table border="0" summary="manufactured viewport for HTML img" style="cellpadding: 0; cellspacing: 0;" width="NaN"><tr><td><img src="../images/gitlab/branches.png" width="NaN" /></td></tr></table></div>
3737
</li><li class="step">
@@ -44,7 +44,7 @@
4444
</li></ol></div>
4545
<p>重复上面步骤,完成development分支的创建。</p>
4646
<p>保护分支:锁定分支,只允允许合并,不允许提交</p>
47-
<div class="procedure"><a id="idp63"></a><p class="title"><strong>过程 2.5. 保护分支</strong></p><ol class="procedure" type="1"><li class="step">
47+
<div class="procedure"><a id="idp64"></a><p class="title"><strong>过程 2.5. 保护分支</strong></p><ol class="procedure" type="1"><li class="step">
4848
<p>master</p>
4949
<p>testing</p>
5050
</li><li class="step">

project/gitlab/group.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<a xmlns="" href="//www.netkiller.cn/home/video.html">视频教程</a> |
1515
<a xmlns="" href="//www.netkiller.cn/home/about.html">About</a><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.3. 创建组与项目</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="user.html">上一页</a> </td><th width="60%" align="center">第 2 章 Gitlab 项目管理</th><td width="20%" align="right"> <a accesskey="n" href="branch.html">下一页</a></td></tr></table><hr /></div><table xmlns=""><tr><td><iframe src="//ghbtns.com/github-btn.html?user=netkiller&amp;repo=netkiller.github.io&amp;type=watch&amp;count=true&amp;size=large" height="30" width="170" frameborder="0" scrolling="0" style="width:170px; height: 30px;" allowTransparency="true"></iframe></td><td><iframe src="//ghbtns.com/github-btn.html?user=netkiller&amp;repo=netkiller.github.io&amp;type=fork&amp;count=true&amp;size=large" height="30" width="170" frameborder="0" scrolling="0" style="width:170px; height: 30px;" allowTransparency="true"></iframe></td><td><iframe src="//ghbtns.com/github-btn.html?user=netkiller&amp;type=follow&amp;count=true&amp;size=large" height="30" width="240" frameborder="0" scrolling="0" style="width:240px; height: 30px;" allowTransparency="true"></iframe></td></tr></table><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="group"></a>2.3. 创建组与项目</h2></div></div></div>
1616

17-
<div class="procedure"><a id="idp60"></a><p class="title"><strong>过程 2.2. Gitlab 初始化 - 创建组</strong></p><ol class="procedure" type="1"><li class="step">
17+
<div class="procedure"><a id="idp61"></a><p class="title"><strong>过程 2.2. Gitlab 初始化 - 创建组</strong></p><ol class="procedure" type="1"><li class="step">
1818
<p>点击 New Group 按钮新建一个组,我习惯每个域一个组,所以我使用 netkiller.cn 作为组名称
1919
</p>
2020
<div><table border="0" summary="manufactured viewport for HTML img" style="cellpadding: 0; cellspacing: 0;" width="NaN"><tr><td><img src="../images/gitlab/group.png" width="NaN" /></td></tr></table></div>
@@ -26,7 +26,7 @@
2626
<div><table border="0" summary="manufactured viewport for HTML img" style="cellpadding: 0; cellspacing: 0;" width="NaN"><tr><td><img src="../images/gitlab/groups.png" width="NaN" /></td></tr></table></div>
2727
</li></ol></div>
2828
<p>创建组后接下来创建项目</p>
29-
<div class="procedure"><a id="idp61"></a><p class="title"><strong>过程 2.3. Gitlab 初始化 - 创建项目</strong></p><ol class="procedure" type="1"><li class="step">
29+
<div class="procedure"><a id="idp62"></a><p class="title"><strong>过程 2.3. Gitlab 初始化 - 创建项目</strong></p><ol class="procedure" type="1"><li class="step">
3030
<p>单击 New Project 创建项目</p>
3131
<div><table border="0" summary="manufactured viewport for HTML img" style="cellpadding: 0; cellspacing: 0;" width="NaN"><tr><td><img src="../images/gitlab/projects.png" width="NaN" /></td></tr></table></div>
3232
</li><li class="step">

project/gitlab/user.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<a xmlns="" href="//www.netkiller.cn/home/video.html">视频教程</a> |
1515
<a xmlns="" href="//www.netkiller.cn/home/about.html">About</a><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.2. 创建用户</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="index.html">上一页</a> </td><th width="60%" align="center">第 2 章 Gitlab 项目管理</th><td width="20%" align="right"> <a accesskey="n" href="group.html">下一页</a></td></tr></table><hr /></div><table xmlns=""><tr><td><iframe src="//ghbtns.com/github-btn.html?user=netkiller&amp;repo=netkiller.github.io&amp;type=watch&amp;count=true&amp;size=large" height="30" width="170" frameborder="0" scrolling="0" style="width:170px; height: 30px;" allowTransparency="true"></iframe></td><td><iframe src="//ghbtns.com/github-btn.html?user=netkiller&amp;repo=netkiller.github.io&amp;type=fork&amp;count=true&amp;size=large" height="30" width="170" frameborder="0" scrolling="0" style="width:170px; height: 30px;" allowTransparency="true"></iframe></td><td><iframe src="//ghbtns.com/github-btn.html?user=netkiller&amp;type=follow&amp;count=true&amp;size=large" height="30" width="240" frameborder="0" scrolling="0" style="width:240px; height: 30px;" allowTransparency="true"></iframe></td></tr></table><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="user"></a>2.2. 创建用户</h2></div></div></div>
1616

17-
<div class="procedure"><a id="idp58"></a><p class="title"><strong>过程 2.1. 企业内部使用的 Gitlab 初始化</strong></p><ol class="procedure" type="1"><li class="step">
17+
<div class="procedure"><a id="idp59"></a><p class="title"><strong>过程 2.1. 企业内部使用的 Gitlab 初始化</strong></p><ol class="procedure" type="1"><li class="step">
1818
<p>关闭在线用户注册</p>
1919

2020
</li><li class="step">

0 commit comments

Comments
 (0)