Wiki source code of XWiki's Continuous Build

Version 21.1 by Vincent Massol on 2019/03/03 15:55

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://maven.xwiki.org]].
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 Pipelines =
21
22 == Main Pipeline ==
23
24 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:
25
26 * Automatically build branches when new branches are added (or Pull Requests). Automatically stop building branches when they are removed from the SCM.
27 * Automatically use the right version of Java (and proper memory configuration)
28 * Use Jenkins's Xvnc plugin to have a Display for functional tests
29 * Use the "deploy" maven goal for "master" and "stable-*" branches only and "install" for the rest
30 * [[Attach the screenshot>>http://massol.myxwiki.org/xwiki/bin/view/Blog/AttachFailingTestPipeline]] of a failing XWiki Selenium test to the failed test's description
31 * 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]]
32 * Send mails for build failures
33
34 To use is for a project, add a ##Jenkinsfile## with the following minimal configuration:
35
36 {{code language="groovy"}}
37 /*
38 * See the NOTICE file distributed with this work for additional
39 * information regarding copyright ownership.
40 *
41 * This is free software; you can redistribute it and/or modify it
42 * under the terms of the GNU Lesser General Public License as
43 * published by the Free Software Foundation; either version 2.1 of
44 * the License, or (at your option) any later version.
45 *
46 * This software is distributed in the hope that it will be useful,
47 * but WITHOUT ANY WARRANTY; without even the implied warranty of
48 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
49 * Lesser General Public License for more details.
50 *
51 * You should have received a copy of the GNU Lesser General Public
52 * License along with this software; if not, write to the Free
53 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
54 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
55 */
56
57 // It's assumed that Jenkins has been configured to implicitly load the vars/xwikiModule.groovy library which exposes
58 // the "xwikiModule" global function/DSL.
59 // Note that the version used is the one defined in Jenkins but it can be overridden as follows:
60 // @Library("XWiki@<branch, tag, sha1>") _
61 // See https://github.com/jenkinsci/workflow-cps-global-lib-plugin for details.
62
63 xwikiModule {
64 }
65 {{/code}}
66
67 For more elaborate configuration, see:
68 * {{scm project="xwiki-commons" path="Jenkinsfile"}}xwiki-commons's Jenkinsfile{{/scm}}
69 * {{scm project="xwiki-platform" path="Jenkinsfile"}}xwiki-platform's Jenkinsfile{{/scm}}
70
71 == Clover Pipeline ==
72
73 Used to generate the global test coverage for XWiki (over all XWiki Standard repositories). See [[Test Coverage>>Community.Testing.TestCoverage.WebHome]].
74
75 Example usage:
76
77 {{code language="groovy"}}
78 import org.xwiki.jenkins.Clover
79 node('docker') {
80 new Clover().generateGlobalCoverage([
81 [baseline: "20171222-1835", fail: false],
82 [baseline: "20190101-2330", fail: true]
83 ])
84 }
85 {{/code}}
86
87 == Docker Pipeline ==
88
89 Used to run functional tests using Docker in various supported configurations. See the [[defined Jobs>>Community.Testing.DockerTesting.WebHome#HCIJobs]].
90
91 Example usage:
92
93 {{code language="groovy"}}
94 import org.xwiki.jenkins.DockerTests
95
96 def branchNames = ['master', 'stable-10.11.x']
97 def branches = [:]
98
99 branchNames.each() {
100 branches[it] = {
101 def label
102 if (it.contains('10.11.x')) {
103 label = 'docker-outside-docker'
104 } else {
105 label = 'docker'
106 }
107 node(label) {
108 new DockerTests().executeDockerSupportedTests(it)
109 }
110 }
111 }
112
113 parallel branches
114 {{/code}}
115
116 = Maintainer's guide =
117
118 == Prerequisites ==
119
120 * 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.
121 * You need to have an administrator account on [[ci.xwiki.org>>http://ci.xwiki.org/signup]].
122
123 == Functional tests ==
124
125 === General ===
126
127 * If your project includes [[functional tests>>http://selenium.openqa.org/]] don't check "Run Xvnc during build" in the project configuration, we have a XVNC server always running on the machine and jenkins is aware of it (DISPLAY :1.0).
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.
139
140 === Jenkins jamming up ===
141
142 Occasionally (especially under high load) Jenkins will have an SCM polling thread jam up due to [[JENKINS-5413>>https://issues.jenkins-ci.org/browse/JENKINS-5413]]. This will prevent any further builds but it can be remedied by running the following script on the master's script console.
143
144 {{code language="groovy"}}
145 int i = 0;
146 Thread.getAllStackTraces().keySet().each(){ item ->
147 if( item.getName().contains("SCM polling") &&
148 item.getName().contains("waiting for hudson.remoting")){
149 println("THREAD: " + item);
150 item.interrupt();
151 i++
152 }
153 }
154 println("count = " + i);
155 {{/code}}

Get Connected