Wiki source code of Continuous Integration

Version 26.4 by Vincent Massol on 2019/03/22 11:59

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

Get Connected