Changes for page Continuous Integration

Last modified by Vincent Massol on 2019/10/16 14:00

From version 28.1
edited by Vincent Massol
on 2019/04/02 15:46
To version 29.1
edited by Vincent Massol
on 2019/06/06 15:22
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -31,6 +31,7 @@
31 31  * [[Attach the screenshot>>http://massol.myxwiki.org/xwiki/bin/view/Blog/AttachFailingTestPipeline]] of a failing XWiki Selenium test to the failed test's description
32 32  * 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]]
33 33  * Send mails for build failures
34 +* Supports passing custom job properties. See below for an example of how to use this to trigger nightly build of Docker-based configuration tests.
34 34  
35 35  Note that if you use a "Github Organization" job type in Jenkins you'll get branch management for free, i.e. automatically build branches when new branches are added (or Pull Requests), and automatically stop building branches when they are removed from the SCM.
36 36  
... ... @@ -71,6 +71,80 @@
71 71  * {{scm project="xwiki-commons" path="Jenkinsfile"}}xwiki-commons's Jenkinsfile{{/scm}}
72 72  * {{scm project="xwiki-platform" path="Jenkinsfile"}}xwiki-platform's Jenkinsfile{{/scm}}
73 73  
75 +=== Nightly Configuration Tests ===
76 +
77 +Heres an example of how you can setup your ##Jenkinsfile## to automatically have execution of Docker-based configuration tests every night. This example is taken from {{scm project="xwiki-platform" path="Jenkinsfile"}}xwiki-platform's Jenkinsfile{{/scm}}.
78 +
79 +* Step 1: In the ##xwikiBuild## step, pass the ##jobProperties## configuration with some scheduler cron. For example:(((
80 +{{code language="groovy"}}
81 +xwikiBuild(map.name) {
82 + ...
83 + jobProperties = getCustomJobProperties()
84 + ...
85 +}
86 +
87 +private def getCustomJobProperties()
88 +{
89 + // Define a scheduler job to execute the Docker-based functional tests at regular intervals. We do this since they
90 + // take time to execute and thus we cannot run them all the time.
91 + // This scheduler job will pass the "type" parameter to this Jenkinsfile when it executes, allowing us to decide if
92 + // we run the standard builds or the docker ones.
93 + // Note: it's the xwikiBuild() calls from the standard builds that will set the jobProperties and thus set up the
94 + // job parameter + the crons. It would be better to set the properties directly in this Jenkinsfile but we haven't
95 + // found a way to merge properties and calling the properties() step will override any pre-existing properties.
96 + return [
97 + parameters([string(defaultValue: 'standard', description: 'Job type', name: 'type')]),
98 + pipelineTriggers([
99 + parameterizedCron('''@midnight %type=docker-latest
100 [email protected] %type=docker-all
101 [email protected] %type=docker-unsupported'''),
102 + cron("@monthly")
103 + ])
104 + ]
105 +}
106 +{{/code}}
107 +)))
108 +* Step 2: Based on the parametrized ##type## value, decide to execute Docker-based tests:(((
109 +{{code language="groovy"}}
110 +...
111 +if (params.type && params.type == 'docker-latest') {
112 + buildDocker('docker-latest')
113 +}
114 +...
115 +private void buildDocker(type)
116 +{
117 + def dockerConfigurationList
118 + def dockerModuleList
119 + def customJobProperties
120 + node() {
121 + // Checkout platform to find all docker configurations and test modules so that we can then parallelize executions
122 + // of configs and modules across Jenkins agents.
123 + checkout skipChangeLog: true, scm: scm
124 + dockerConfigurationList = dockerConfigurations(type)
125 + if (type == 'docker-unsupported') {
126 + dockerModuleList = ['xwiki-platform-core/xwiki-platform-menu']
127 + } else {
128 + dockerModuleList = dockerModules()
129 + }
130 + customJobProperties = getCustomJobProperties()
131 + }
132 +
133 + xwikiDockerBuild {
134 + configurations = dockerConfigurationList
135 + modules = dockerModuleList
136 + // Make sure that we don't reset the job properties!
137 + jobProperties = customJobProperties
138 + }
139 +}
140 +{{/code}}
141 +)))
142 +
143 +Pros/Cons of this approach (which is needed because Jenkins doesn't support more than one ##Jenkinsfile##) vs using a separate job:
144 +* Pros:
145 +** No need to handle branches, done automatically by the ##Jenkinsfile## (creation and deletion). Also works for PRs.
146 +* Cons:
147 +** Jenkins build history gets a bit messed up (but test history is kept).
148 +
74 74  == Clover Pipeline ==
75 75  
76 76  Used to generate the global test coverage for XWiki (over all XWiki Standard repositories). See [[Test Coverage>>Community.Testing.TestCoverage.WebHome]].
... ... @@ -87,35 +87,6 @@
87 87  }
88 88  {{/code}}
89 89  
90 -== Docker Pipeline ==
91 -
92 -Used to run functional tests using Docker in various supported configurations. See the [[defined Jobs>>Community.Testing.DockerTesting.WebHome#HCIJobs]].
93 -
94 -Example usage:
95 -
96 -{{code language="groovy"}}
97 -import org.xwiki.jenkins.DockerTests
98 -
99 -def branchNames = ['master', 'stable-10.11.x']
100 -def branches = [:]
101 -
102 -branchNames.each() {
103 - branches[it] = {
104 - def label
105 - if (it.contains('10.11.x')) {
106 - label = 'docker-outside-docker'
107 - } else {
108 - label = 'docker'
109 - }
110 - node(label) {
111 - new DockerTests().executeDockerSupportedTests(it)
112 - }
113 - }
114 -}
115 -
116 -parallel branches
117 -{{/code}}
118 -
119 119  = Maintainer's guide =
120 120  
121 121  == Prerequisites ==

Get Connected