Wiki source code of XWiki's Continuous Build

Version 25.1 by Vincent Massol on 2019/03/03 16:16

Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 = General =
6
7 XWiki has a [[Continuous Integration>>http://www.martinfowler.com/articles/continuousIntegration.html]] setup to ensure XWiki's code is built at all times (i.e at every code check in). This also allows developers to only build the module they want and they'll have the other XWiki module dependencies downloaded from the [[XWiki remote repository>>http://nexus.xwiki.org/nexus/#view-repositories]].
8
9 {{image reference="xwikibuildprocess.png"/}}
10
11 We use the following tools:
12
13 * [[GitHub>>https://github.com/xwiki]] is used as our [[SCM>>http://en.wikipedia.org/wiki/Source_Code_Management]]
14 * [[Maven>>http://maven.apache.org/]] is used for [[building XWiki>>Community.Building]]
15 * [[Jenkins>>http://jenkins-ci.org/]] is used as our Continuous Integration (CI) tool (set up at [[http://ci.xwiki.org/]])
16 * [[Docker>>https://www.docker.com/docker-community]] is used to run Jenkins agents (and incidentally to execute some functional tests over various configurations)
17
18 We use a technique called [[binary dependency build>>http://web.archive.org/web/20090423073100/http://blogs.codehaus.org/people/vmassol/archives/000953_binary_dependency_builds.html]] which allows to check out only the module a developer wishes to work on and he'll automatically get the latest fresh binary dependencies built by our CI tool.
19
20 = Jenkins Agent Image =
21
22 XWiki has its own {{scm project="xwiki-jenkins-slave" path="Dockerfile"}}Jenkins Agent Docker image{{/scm}} that is used by Jenkins master to spawn agents.
23
24 = Jenkins Pipelines =
25
26 == Main Pipeline ==
27
28 We have developed a {{scm project="xwiki-jenkins-pipeline" path="vars/xwikiModule.groovy"}}Jenkins Pipeline script{{/scm}} to build XWiki projects (can be used for core and contrib projects). It has the following features:
29
30 * Automatically build branches when new branches are added (or Pull Requests). Automatically stop building branches when they are removed from the SCM.
31 * Automatically use the right version of Java (and proper memory configuration)
32 * Use Jenkins's Xvnc plugin to have a Display for functional tests
33 * Use the "deploy" maven goal for "master" and "stable-*" branches only and "install" for the rest
34 * [[Attach the screenshot>>http://massol.myxwiki.org/xwiki/bin/view/Blog/AttachFailingTestPipeline]] of a failing XWiki Selenium test to the failed test's description
35 * Check for false positives for known cases of failures not related to code + [[check for test flickers>>http://massol.myxwiki.org/xwiki/bin/view/Blog/FlakyTestTool]]
36 * Send mails for build failures
37
38 To use is for a project, add a ##Jenkinsfile## with the following minimal configuration:
39
40 {{code language="groovy"}}
41 /*
42 * See the NOTICE file distributed with this work for additional
43 * information regarding copyright ownership.
44 *
45 * This is free software; you can redistribute it and/or modify it
46 * under the terms of the GNU Lesser General Public License as
47 * published by the Free Software Foundation; either version 2.1 of
48 * the License, or (at your option) any later version.
49 *
50 * This software is distributed in the hope that it will be useful,
51 * but WITHOUT ANY WARRANTY; without even the implied warranty of
52 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
53 * Lesser General Public License for more details.
54 *
55 * You should have received a copy of the GNU Lesser General Public
56 * License along with this software; if not, write to the Free
57 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
58 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
59 */
60
61 // It's assumed that Jenkins has been configured to implicitly load the vars/xwikiModule.groovy library which exposes
62 // the "xwikiModule" global function/DSL.
63 // Note that the version used is the one defined in Jenkins but it can be overridden as follows:
64 // @Library("XWiki@<branch, tag, sha1>") _
65 // See https://github.com/jenkinsci/workflow-cps-global-lib-plugin for details.
66
67 xwikiModule {
68 }
69 {{/code}}
70
71 For more elaborate configuration, see:
72 * {{scm project="xwiki-commons" path="Jenkinsfile"}}xwiki-commons's Jenkinsfile{{/scm}}
73 * {{scm project="xwiki-platform" path="Jenkinsfile"}}xwiki-platform's Jenkinsfile{{/scm}}
74
75 == Clover Pipeline ==
76
77 Used to generate the global test coverage for XWiki (over all XWiki Standard repositories). See [[Test Coverage>>Community.Testing.TestCoverage.WebHome]].
78
79 Example usage:
80
81 {{code language="groovy"}}
82 import org.xwiki.jenkins.Clover
83 node('docker') {
84 new Clover().generateGlobalCoverage([
85 [baseline: "20171222-1835", fail: false],
86 [baseline: "20190101-2330", fail: true]
87 ])
88 }
89 {{/code}}
90
91 == Docker Pipeline ==
92
93 Used to run functional tests using Docker in various supported configurations. See the [[defined Jobs>>Community.Testing.DockerTesting.WebHome#HCIJobs]].
94
95 Example usage:
96
97 {{code language="groovy"}}
98 import org.xwiki.jenkins.DockerTests
99
100 def branchNames = ['master', 'stable-10.11.x']
101 def branches = [:]
102
103 branchNames.each() {
104 branches[it] = {
105 def label
106 if (it.contains('10.11.x')) {
107 label = 'docker-outside-docker'
108 } else {
109 label = 'docker'
110 }
111 node(label) {
112 new DockerTests().executeDockerSupportedTests(it)
113 }
114 }
115 }
116
117 parallel branches
118 {{/code}}
119
120 = Maintainer's guide =
121
122 == Prerequisites ==
123
124 * You need to have an account on [[maven.xwiki.org>>http://maven.xwiki.org/]] (this is the machine hosting XWiki's remote repository) and you'll need a key setup on your account there so that you can ssh to it without having to enter username or password.
125 * You need to have an administrator account on [[ci.xwiki.org>>http://ci.xwiki.org/signup]].
126
127 == Functional tests ==
128
129 === Debugging ===
130
131 **Connect to the XVNC server**
132
133 * Establish a SSH tunnel between your computer and the server on port 5901 (//ssh -L 5901:localhost:5901 [email protected]//)
134 * Use your favorite VNC client to connect to the XVNC server
135 ** Host : localhost
136 ** Display : 1
137 ** Password : same password as for XWiki SAS wifi access points
138 * See the functional tests live.

Get Connected