[TASK] Activate bamboo nightly mssql functional tests
[Packages/TYPO3.CMS.git] / Build / bamboo / src / main / java / core / AbstractCoreSpec.java
1 package core;
2
3 /*
4 * This file is part of the TYPO3 CMS project.
5 *
6 * It is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License, either version 2
8 * of the License, or any later version.
9 *
10 * For the full copyright and license information, please read the
11 * LICENSE.txt file that was distributed with this source code.
12 *
13 * The TYPO3 project - inspiring people to share!
14 */
15
16 import java.util.ArrayList;
17
18 import com.atlassian.bamboo.specs.api.builders.BambooKey;
19 import com.atlassian.bamboo.specs.api.builders.permission.PermissionType;
20 import com.atlassian.bamboo.specs.api.builders.permission.Permissions;
21 import com.atlassian.bamboo.specs.api.builders.permission.PlanPermissions;
22 import com.atlassian.bamboo.specs.api.builders.plan.Job;
23 import com.atlassian.bamboo.specs.api.builders.plan.PlanIdentifier;
24 import com.atlassian.bamboo.specs.api.builders.plan.artifact.Artifact;
25 import com.atlassian.bamboo.specs.api.builders.plan.configuration.AllOtherPluginsConfiguration;
26 import com.atlassian.bamboo.specs.api.builders.plan.configuration.PluginConfiguration;
27 import com.atlassian.bamboo.specs.api.builders.requirement.Requirement;
28 import com.atlassian.bamboo.specs.api.builders.task.Task;
29 import com.atlassian.bamboo.specs.builders.task.CheckoutItem;
30 import com.atlassian.bamboo.specs.builders.task.CommandTask;
31 import com.atlassian.bamboo.specs.builders.task.NpmTask;
32 import com.atlassian.bamboo.specs.builders.task.ScriptTask;
33 import com.atlassian.bamboo.specs.builders.task.TestParserTask;
34 import com.atlassian.bamboo.specs.builders.task.VcsCheckoutTask;
35 import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties;
36 import com.atlassian.bamboo.specs.model.task.TestParserTaskProperties;
37 import com.atlassian.bamboo.specs.util.MapBuilder;
38
39 /**
40 * Abstract class with common methods of pre-merge and nightly plan
41 */
42 abstract public class AbstractCoreSpec {
43
44 protected static String bambooServerName = "https://bamboo.typo3.com:443";
45 protected static String projectName = "TYPO3 Core";
46 protected static String projectKey = "CORE";
47
48 protected String composerRootVersionEnvironment = "COMPOSER_ROOT_VERSION=8.7.0";
49
50 protected String testingFrameworkBuildPath = "vendor/typo3/testing-framework/Resources/Core/Build/";
51
52 /**
53 * @todo This can be removed if acceptance mysql tests are rewritten and active again
54 */
55 protected String credentialsMysql =
56 "typo3DatabaseName=\"func\"" +
57 " typo3DatabaseUsername=\"funcu\"" +
58 " typo3DatabasePassword=\"funcp\"" +
59 " typo3DatabaseHost=\"localhost\"" +
60 " typo3InstallToolPassword=\"klaus\"";
61
62 /**
63 * @todo This can be removed if acceptance pgsql tests are rewritten and active again
64 */
65 protected String credentialsPgsql =
66 "typo3DatabaseDriver=\"pdo_pgsql\"" +
67 " typo3DatabaseName=\"func\"" +
68 " typo3DatabaseUsername=\"bamboo\"" +
69 " typo3DatabaseHost=\"localhost\"" +
70 " typo3DatabasePort=\"5433\"" +
71 " typo3InstallToolPassword=\"klaus\"";
72
73 /**
74 * Default permissions on core plans
75 *
76 * @param projectName
77 * @param planName
78 * @return
79 */
80 protected PlanPermissions getDefaultPlanPermissions(String projectKey, String planKey) {
81 return new PlanPermissions(new PlanIdentifier(projectKey, planKey))
82 .permissions(new Permissions()
83 .groupPermissions("TYPO3 GmbH", PermissionType.ADMIN, PermissionType.VIEW, PermissionType.EDIT, PermissionType.BUILD, PermissionType.CLONE)
84 .groupPermissions("TYPO3 Core Team", PermissionType.VIEW, PermissionType.BUILD)
85 .loggedInUserPermissions(PermissionType.VIEW)
86 .anonymousUserPermissionView()
87 );
88 }
89
90 /**
91 * Default plan plugin configuration
92 *
93 * @return
94 */
95 protected PluginConfiguration getDefaultPlanPluginConfiguration() {
96 return new AllOtherPluginsConfiguration()
97 .configuration(new MapBuilder()
98 .put("custom", new MapBuilder()
99 .put("artifactHandlers.useCustomArtifactHandlers", "false")
100 .put("buildExpiryConfig", new MapBuilder()
101 .put("duration", "30")
102 .put("period", "days")
103 .put("labelsToKeep", "")
104 .put("expiryTypeResult", "true")
105 .put("buildsToKeep", "")
106 .put("enabled", "true")
107 .build()
108 )
109 .build()
110 )
111 .build()
112 );
113 }
114
115 /**
116 * Default job plugin configuration
117 *
118 * @return
119 */
120 protected PluginConfiguration getDefaultJobPluginConfiguration() {
121 return new AllOtherPluginsConfiguration()
122 .configuration(new MapBuilder()
123 .put("repositoryDefiningWorkingDirectory", -1)
124 .put("custom", new MapBuilder()
125 .put("auto", new MapBuilder()
126 .put("regex", "")
127 .put("label", "")
128 .build()
129 )
130 .put("buildHangingConfig.enabled", "false")
131 .put("ncover.path", "")
132 .put("clover", new MapBuilder()
133 .put("path", "")
134 .put("license", "")
135 .put("useLocalLicenseKey", "true")
136 .build()
137 )
138 .build()
139 )
140 .build()
141 );
142 }
143
144 /**
145 * Job composer validate
146 *
147 * @param String requirementIdentifier
148 */
149 protected Job getJobComposerValidate(String requirementIdentifier) {
150 return new Job("Validate composer.json", new BambooKey("VC"))
151 .description("Validate composer.json before actual tests are executed")
152 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
153 .tasks(
154 this.getTaskGitCloneRepository(),
155 this.getTaskGitCherryPick(),
156 new ScriptTask()
157 .description("composer validate")
158 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
159 .inlineBody(
160 this.getScriptTaskBashInlineBody() +
161 this.getScriptTaskComposer(requirementIdentifier) +
162 "composer validate"
163 )
164 .environmentVariables(this.composerRootVersionEnvironment)
165 )
166 .requirements(
167 this.getRequirementDocker10()
168 )
169 .cleanWorkingDirectory(true);
170 }
171
172 /**
173 * Job acceptance test installs system on mysql
174 *
175 * @param String requirementIdentfier
176 */
177 protected Job getJobAcceptanceTestInstallMysql(String requirementIdentifier) {
178 return new Job("Accept inst my " + requirementIdentifier, new BambooKey("ACINSTMY" + requirementIdentifier))
179 .description("Install TYPO3 on mysql and create empty frontend page " + requirementIdentifier)
180 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
181 .tasks(
182 this.getTaskGitCloneRepository(),
183 this.getTaskGitCherryPick(),
184 this.getTaskComposerInstall(requirementIdentifier),
185 this.getTaskPrepareAcceptanceTest(),
186 new CommandTask()
187 .description("Execute codeception AcceptanceInstallMysql suite")
188 .executable("codecept")
189 .argument("run AcceptanceInstallMysql -d -c " + this.testingFrameworkBuildPath + "AcceptanceTestsInstallMysql.yml --xml reports.xml --html reports.html")
190 .environmentVariables(this.credentialsMysql)
191 )
192 .finalTasks(
193 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
194 .resultDirectories("typo3temp/var/tests/AcceptanceReportsInstallMysql/reports.xml")
195 )
196 .requirements(
197 this.getRequirementDocker10()
198 )
199 .artifacts(new Artifact()
200 .name("Test Report")
201 .copyPattern("typo3temp/var/tests/AcceptanceReportsInstallMysql/")
202 .shared(false)
203 )
204 .cleanWorkingDirectory(true)
205 .enabled(false);
206 }
207
208 /**
209 * Job acceptance test installs system and introduction package on pgsql
210 *
211 * @param String requirementIdentfier
212 */
213 protected Job getJobAcceptanceTestInstallPgsql(String requirementIdentifier) {
214 return new Job("Accept inst pg " + requirementIdentifier, new BambooKey("ACINSTPG" + requirementIdentifier))
215 .description("Install TYPO3 on pgsql and load introduction package " + requirementIdentifier)
216 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
217 .tasks(
218 this.getTaskGitCloneRepository(),
219 this.getTaskGitCherryPick(),
220 this.getTaskComposerInstall(requirementIdentifier),
221 this.getTaskPrepareAcceptanceTest(),
222 new CommandTask()
223 .description("Execute codeception AcceptanceInstallPgsql suite")
224 .executable("codecept")
225 .argument("run AcceptanceInstallPgsql -d -c " + this.testingFrameworkBuildPath + "AcceptanceTestsInstallPgsql.yml --xml reports.xml --html reports.html")
226 .environmentVariables(this.credentialsPgsql)
227 )
228 .finalTasks(
229 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
230 .resultDirectories("typo3temp/var/tests/AcceptanceReportsInstallPgsql/reports.xml")
231 )
232 .requirements(
233 this.getRequirementDocker10()
234 )
235 .artifacts(new Artifact()
236 .name("Test Report")
237 .copyPattern("typo3temp/var/tests/AcceptanceReportsInstallPgsql/")
238 .shared(false)
239 )
240 .cleanWorkingDirectory(true)
241 .enabled(false);
242 }
243
244 /**
245 * Jobs for mysql based acceptance tests
246 *
247 * @param int numberOfChunks
248 * @param String requirementIdentifier
249 */
250 protected ArrayList<Job> getJobsAcceptanceTestsMysql(int numberOfChunks, String requirementIdentifier) {
251 ArrayList<Job> jobs = new ArrayList<Job>();
252
253 for (int i=1; i<=numberOfChunks; i++) {
254 jobs.add(new Job("Accept my " + requirementIdentifier + " 0" + i, new BambooKey("ACMY" + requirementIdentifier + "0" + i))
255 .description("Run acceptance tests" + requirementIdentifier)
256 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
257 .tasks(
258 this.getTaskGitCloneRepository(),
259 this.getTaskGitCherryPick(),
260 this.getTaskComposerInstall(requirementIdentifier),
261 this.getTaskPrepareAcceptanceTest(),
262 new ScriptTask()
263 .description("Split acceptance tests")
264 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
265 .inlineBody(
266 this.getScriptTaskBashInlineBody() +
267 "./" + this.testingFrameworkBuildPath + "Scripts/splitAcceptanceTests.sh " + numberOfChunks + "\n"
268 ),
269 new CommandTask()
270 .description("Execute codeception acceptance suite group " + i)
271 .executable("codecept")
272 .argument("run Acceptance -d -g AcceptanceTests-Job-" + i + " -c " + this.testingFrameworkBuildPath + "AcceptanceTests.yml --xml reports.xml --html reports.html")
273 .environmentVariables(this.credentialsMysql)
274 )
275 .finalTasks(
276 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
277 .resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml")
278 )
279 .requirements(
280 this.getRequirementDocker10()
281 )
282 .artifacts(new Artifact()
283 .name("Test Report")
284 .copyPattern("typo3temp/var/tests/AcceptanceReports/")
285 .shared(false)
286 )
287 .cleanWorkingDirectory(true)
288 .enabled(false)
289 );
290 }
291
292 return jobs;
293 }
294
295 /**
296 * Jobs for mysql based functional tests
297 *
298 * @param int numberOfChunks
299 * @param String requirementIdentifier
300 */
301 protected ArrayList<Job> getJobsFunctionalTestsMysql(int numberOfChunks, String requirementIdentifier) {
302 ArrayList<Job> jobs = new ArrayList<Job>();
303
304 for (int i=0; i<numberOfChunks; i++) {
305 jobs.add(new Job("Func mysql " + requirementIdentifier + " 0" + i, new BambooKey("FMY" + requirementIdentifier + "0" + i))
306 .description("Run functional tests on mysql DB " + requirementIdentifier)
307 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
308 .tasks(
309 this.getTaskGitCloneRepository(),
310 this.getTaskGitCherryPick(),
311 this.getTaskComposerInstall(requirementIdentifier),
312 this.getTaskDockerDependenciesFunctionalMariadb10(),
313 this.getTaskSplitFunctionalJobs(numberOfChunks),
314 new ScriptTask()
315 .description("Run phpunit with functional chunk 0" + i)
316 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
317 .inlineBody(
318 this.getScriptTaskBashInlineBody() +
319 "function phpunit() {\n" +
320 " docker run \\\n" +
321 " -u ${HOST_UID} \\\n" +
322 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
323 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
324 " -e typo3DatabaseName=func_test \\\n" +
325 " -e typo3DatabaseUsername=root \\\n" +
326 " -e typo3DatabasePassword=funcp \\\n" +
327 " -e typo3DatabaseHost=mariadb10 \\\n" +
328 " -e typo3TestingRedisHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_redis4_1 \\\n" +
329 " -e typo3TestingMemcachedHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_memcached1-5_1 \\\n" +
330 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
331 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
332 " --rm \\\n" +
333 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
334 " bin/bash -c \"cd ${PWD}; ./bin/phpunit $*\"\n" +
335 "}\n" +
336 "\n" +
337 "phpunit --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "FunctionalTests-Job-" + i + ".xml"
338 )
339 )
340 .finalTasks(
341 this.getTaskStopDockerDependencies(),
342 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
343 .resultDirectories("test-reports/phpunit.xml")
344 )
345 .requirements(
346 this.getRequirementDocker10()
347 )
348 .cleanWorkingDirectory(true)
349 );
350 }
351
352 return jobs;
353 }
354
355 /**
356 * Jobs for mssql based functional tests
357 *
358 * @param int numberOfChunks
359 * @param String requirementIdentifier
360 */
361 protected ArrayList<Job> getJobsFunctionalTestsMssql(int numberOfChunks, String requirementIdentifier) {
362 ArrayList<Job> jobs = new ArrayList<Job>();
363
364 for (int i=0; i<numberOfChunks; i++) {
365 jobs.add(new Job("Func mssql " + requirementIdentifier + " 0" + i, new BambooKey("FMS" + requirementIdentifier + "0" + i))
366 .description("Run functional tests on mssql DB " + requirementIdentifier)
367 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
368 .tasks(
369 this.getTaskGitCloneRepository(),
370 this.getTaskGitCherryPick(),
371 this.getTaskComposerInstall(requirementIdentifier),
372 this.getTaskDockerDependenciesFunctionalMssql(),
373 this.getTaskSplitFunctionalJobs(numberOfChunks),
374 new ScriptTask()
375 .description("Run phpunit with functional chunk 0" + i)
376 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
377 .inlineBody(
378 this.getScriptTaskBashInlineBody() +
379 "function phpunit() {\n" +
380 " docker run \\\n" +
381 " -u ${HOST_UID} \\\n" +
382 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
383 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
384 " -e typo3DatabaseDriver=sqlsrv \\\n" +
385 " -e typo3DatabaseName=func \\\n" +
386 " -e typo3DatabasePassword=Test1234! \\\n" +
387 " -e typo3DatabaseUsername=SA \\\n" +
388 " -e typo3DatabaseHost=localhost \\\n" +
389 " -e typo3DatabasePort=1433 \\\n" +
390 " -e typo3DatabaseCharset=utf-8 \\\n" +
391 " -e typo3DatabaseHost=mssql2017cu9 \\\n" +
392 " -e typo3TestingRedisHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_redis4_1 \\\n" +
393 " -e typo3TestingMemcachedHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_memcached1-5_1 \\\n" +
394 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
395 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
396 " --rm \\\n" +
397 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
398 " bin/bash -c \"cd ${PWD}; ./bin/phpunit $*\"\n" +
399 "}\n" +
400 "\n" +
401 "phpunit --exclude-group not-mssql --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "FunctionalTests-Job-" + i + ".xml"
402 )
403 )
404 .finalTasks(
405 this.getTaskStopDockerDependencies(),
406 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
407 .resultDirectories("test-reports/phpunit.xml")
408 )
409 .requirements(
410 this.getRequirementDocker10()
411 )
412 .cleanWorkingDirectory(true)
413 );
414 }
415
416 return jobs;
417 }
418
419 /**
420 * Jobs for pgsql based functional tests
421 *
422 * @param int numberOfChunks
423 * @param String requirementIdentifier
424 */
425 protected ArrayList<Job> getJobsFunctionalTestsPgsql(int numberOfChunks, String requirementIdentifier) {
426 ArrayList<Job> jobs = new ArrayList<Job>();
427
428 for (int i=0; i<numberOfChunks; i++) {
429 jobs.add(new Job("Func pgsql " + requirementIdentifier + " 0" + i, new BambooKey("FPG" + requirementIdentifier + "0" + i))
430 .description("Run functional tests on pgsql DB " + requirementIdentifier)
431 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
432 .tasks(
433 this.getTaskGitCloneRepository(),
434 this.getTaskGitCherryPick(),
435 this.getTaskComposerInstall(requirementIdentifier),
436 this.getTaskDockerDependenciesFunctionalPostgres95(),
437 this.getTaskSplitFunctionalJobs(numberOfChunks),
438 new ScriptTask()
439 .description("Run phpunit with functional chunk 0" + i)
440 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
441 .inlineBody(
442 this.getScriptTaskBashInlineBody() +
443 "function phpunit() {\n" +
444 " docker run \\\n" +
445 " -u ${HOST_UID} \\\n" +
446 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
447 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
448 " -e typo3DatabaseDriver=pdo_pgsql \\\n" +
449 " -e typo3DatabaseName=bamboo \\\n" +
450 " -e typo3DatabaseUsername=bamboo \\\n" +
451 " -e typo3DatabaseHost=postgres9-5 \\\n" +
452 " -e typo3DatabasePassword=funcp \\\n" +
453 " -e typo3TestingRedisHost=redis4 \\\n" +
454 " -e typo3TestingMemcachedHost=memcached1-5 \\\n" +
455 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
456 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
457 " --rm \\\n" +
458 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
459 " bin/bash -c \"cd ${PWD}; ./bin/phpunit $*\"\n" +
460 "}\n" +
461 "\n" +
462 "phpunit --exclude-group not-postgres --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "FunctionalTests-Job-" + i + ".xml"
463 )
464 )
465 .finalTasks(
466 this.getTaskStopDockerDependencies(),
467 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
468 .resultDirectories("test-reports/phpunit.xml")
469 )
470 .requirements(
471 this.getRequirementDocker10()
472 )
473 .cleanWorkingDirectory(true)
474 );
475 }
476
477 return jobs;
478 }
479
480 /**
481 * Job with various smaller script tests
482 *
483 * @param String requirementIdentifier
484 */
485 protected Job getJobIntegrationVarious(String requirementIdentifier) {
486 // Exception code checker, xlf, permissions, rst file check
487 return new Job("Integration various", new BambooKey("CDECC"))
488 .description("Checks duplicate exceptions, git submodules, xlf files, permissions, rst")
489 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
490 .tasks(
491 this.getTaskGitCloneRepository(),
492 this.getTaskGitCherryPick(),
493 this.getTaskComposerInstall(requirementIdentifier),
494 new ScriptTask()
495 .description("Run duplicate exception code check script")
496 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
497 .inlineBody(
498 this.getScriptTaskBashInlineBody() +
499 "./Build/Scripts/duplicateExceptionCodeCheck.sh\n"
500 ),
501 new ScriptTask()
502 .description("Run git submodule status and verify there are none")
503 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
504 .inlineBody(
505 this.getScriptTaskBashInlineBody() +
506 "if [[ `git submodule status 2>&1 | wc -l` -ne 0 ]]; then\n" +
507 " echo \\\"Found a submodule definition in repository\\\";\n" +
508 " exit 99;\n" +
509 "fi\n"
510 ),
511 new ScriptTask()
512 .description("Run permission check script")
513 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
514 .inlineBody(
515 this.getScriptTaskBashInlineBody() +
516 "./Build/Scripts/checkFilePermissions.sh\n"
517 ),
518 new ScriptTask()
519 .description("Run xlf check")
520 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
521 .inlineBody(
522 this.getScriptTaskBashInlineBody() +
523 "./Build/Scripts/xlfcheck.sh"
524 ),
525 new ScriptTask()
526 .description("Run rst check")
527 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
528 .inlineBody(
529 this.getScriptTaskBashInlineBody() +
530 "function validateRstFiles() {\n" +
531 " docker run \\\n" +
532 " -u ${HOST_UID} \\\n" +
533 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
534 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
535 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
536 " --rm \\\n" +
537 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
538 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/validateRstFiles.php $*\"\n" +
539 "}\n" +
540 "\n" +
541 "validateRstFiles"
542 ),
543 new ScriptTask()
544 .description("Run path length check")
545 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
546 .inlineBody(
547 this.getScriptTaskBashInlineBody() +
548 "./Build/Scripts/maxFilePathLength.sh"
549 ),
550 new ScriptTask()
551 .description("Run functional fixture csv format checker")
552 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
553 .inlineBody(
554 this.getScriptTaskBashInlineBody() +
555 "function checkIntegrityCsvFixtures() {\n" +
556 " docker run \\\n" +
557 " -u ${HOST_UID} \\\n" +
558 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
559 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
560 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
561 " --rm \\\n" +
562 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
563 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/checkIntegrityCsvFixtures.php $*\"\n" +
564 "}\n" +
565 "\n" +
566 "checkIntegrityCsvFixtures"
567 ),
568 new ScriptTask()
569 .description("Run composer.json integrity check")
570 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
571 .inlineBody(
572 this.getScriptTaskBashInlineBody() +
573 "function checkIntegrityComposer() {\n" +
574 " docker run \\\n" +
575 " -u ${HOST_UID} \\\n" +
576 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
577 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
578 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
579 " --rm \\\n" +
580 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
581 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/checkIntegrityComposer.php $*\"\n" +
582 "}\n" +
583 "\n" +
584 "checkIntegrityComposer"
585 )
586 )
587 .requirements(
588 this.getRequirementDocker10()
589 )
590 .cleanWorkingDirectory(true);
591 }
592
593 /**
594 * Job for javascript unit tests
595 *
596 * @param String requirementIdentifier
597 */
598 protected Job getJobUnitJavaScript(String requirementIdentifier) {
599 return new Job("Unit JavaScript", new BambooKey("JSUT"))
600 .description("Run JavaScript unit tests")
601 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
602 .tasks(
603 this.getTaskGitCloneRepository(),
604 this.getTaskGitCherryPick(),
605 this.getTaskComposerInstall(requirementIdentifier),
606 new ScriptTask()
607 .description("yarn install in Build/ dir")
608 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
609 .inlineBody(
610 this.getScriptTaskBashInlineBody() +
611 "function yarn() {\n" +
612 " docker run \\\n" +
613 " -u ${HOST_UID} \\\n" +
614 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
615 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
616 " -e HOME=${HOME} \\\n" +
617 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
618 " --rm \\\n" +
619 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
620 " bin/bash -c \"cd ${PWD}/Build; yarn $*\"\n" +
621 "}\n" +
622 "\n" +
623 "yarn install"
624 ),
625 new ScriptTask()
626 .description("Run tests")
627 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
628 .inlineBody(
629 this.getScriptTaskBashInlineBody() +
630 "function karma() {\n" +
631 " docker run \\\n" +
632 " -u ${HOST_UID} \\\n" +
633 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
634 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
635 " -e HOME=${HOME} \\\n" +
636 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
637 " --rm \\\n" +
638 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
639 " bin/bash -c \"cd ${PWD}; ./Build/node_modules/karma/bin/karma $*\"\n" +
640 "}\n" +
641 "\n" +
642 "karma start " + this.testingFrameworkBuildPath + "Configuration/JSUnit/karma.conf.js --single-run"
643 )
644 )
645 .finalTasks(
646 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
647 .resultDirectories("typo3temp/var/tests/*")
648 )
649 .artifacts(
650 new Artifact()
651 .name("Clover Report (System)")
652 .copyPattern("**/*.*")
653 .location("Build/target/site/clover")
654 .shared(false)
655 )
656 .requirements(
657 this.getRequirementDocker10()
658 )
659 .cleanWorkingDirectory(true);
660 }
661
662 /**
663 * Job for PHP lint
664 *
665 * @param String requirementIdentfier
666 */
667 protected Job getJobLintPhp(String requirementIdentifier) {
668 return new Job("Lint " + requirementIdentifier, new BambooKey("L" + requirementIdentifier))
669 .description("Run php -l on source files for linting " + requirementIdentifier)
670 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
671 .tasks(
672 this.getTaskGitCloneRepository(),
673 this.getTaskGitCherryPick(),
674 new ScriptTask()
675 .description("Run php lint")
676 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
677 .inlineBody(
678 this.getScriptTaskBashInlineBody() +
679 "function runLint() {\n" +
680 " docker run \\\n" +
681 " -u ${HOST_UID} \\\n" +
682 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
683 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
684 " -e HOME=${HOME} \\\n" +
685 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
686 " --rm \\\n" +
687 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
688 " bin/bash -c \"cd ${PWD}; find . -name \\*.php -print0 | xargs -0 -n1 -P2 php -n -c /etc/php/cli-no-xdebug/php.ini -l >/dev/null\"\n" +
689 "}\n" +
690 "\n" +
691 "runLint"
692 )
693 )
694 .requirements(
695 this.getRequirementDocker10()
696 )
697 .cleanWorkingDirectory(true);
698 }
699
700 /**
701 * Job for lint npm scss and typescript
702 *
703 * @param String requirementIdentifier
704 */
705 protected Job getJobLintScssTs(String requirementIdentifier) {
706 return new Job("Lint scss ts", new BambooKey("LSTS"))
707 .description("Run npm lint, run npm run build-js")
708 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
709 .tasks(
710 this.getTaskGitCloneRepository(),
711 this.getTaskGitCherryPick(),
712 new ScriptTask()
713 .description("yarn install in Build/ dir")
714 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
715 .inlineBody(
716 this.getScriptTaskBashInlineBody() +
717 "function yarn() {\n" +
718 " docker run \\\n" +
719 " -u ${HOST_UID} \\\n" +
720 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
721 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
722 " -e HOME=${HOME} \\\n" +
723 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
724 " --rm \\\n" +
725 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
726 " bin/bash -c \"cd ${PWD}/Build; yarn $*\"\n" +
727 "}\n" +
728 "\n" +
729 "yarn install"
730 ),
731 new ScriptTask()
732 .description("Run npm lint")
733 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
734 .inlineBody(
735 this.getScriptTaskBashInlineBody() +
736 "function npm() {\n" +
737 " docker run \\\n" +
738 " -u ${HOST_UID} \\\n" +
739 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
740 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
741 " -e HOME=${HOME} \\\n" +
742 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
743 " --rm \\\n" +
744 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
745 " bin/bash -c \"cd ${PWD}/Build; npm $*\"\n" +
746 "}\n" +
747 "\n" +
748 "npm run lint"
749 ),
750 new ScriptTask()
751 .description("Run npm build-js")
752 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
753 .inlineBody(
754 this.getScriptTaskBashInlineBody() +
755 "function npm() {\n" +
756 " docker run \\\n" +
757 " -u ${HOST_UID} \\\n" +
758 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
759 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
760 " -e HOME=${HOME} \\\n" +
761 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
762 " --rm \\\n" +
763 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
764 " bin/bash -c \"cd ${PWD}/Build; npm $*\"\n" +
765 "}\n" +
766 "\n" +
767 "npm run build-js"
768 ),
769 new ScriptTask()
770 .description("git status to check for changed files after build-js")
771 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
772 .inlineBody(
773 this.getScriptTaskBashInlineBody() +
774 "git status | grep -q \"nothing to commit, working tree clean\""
775 )
776 )
777 .requirements(
778 this.getRequirementDocker10()
779 )
780 .cleanWorkingDirectory(true);
781 }
782
783 /**
784 * Job for unit testing PHP
785 *
786 * @param String requirementIdentfier
787 */
788 protected Job getJobUnitPhp(String requirementIdentifier) {
789 return new Job("Unit " + requirementIdentifier, new BambooKey("UT" + requirementIdentifier))
790 .description("Run unit tests " + requirementIdentifier)
791 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
792 .tasks(
793 this.getTaskGitCloneRepository(),
794 this.getTaskGitCherryPick(),
795 this.getTaskComposerInstall(requirementIdentifier),
796 this.getTaskDockerDependenciesUnit(),
797 new ScriptTask()
798 .description("Run phpunit")
799 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
800 .inlineBody(
801 this.getScriptTaskBashInlineBody() +
802 "function phpunit() {\n" +
803 " docker run \\\n" +
804 " -u ${HOST_UID} \\\n" +
805 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
806 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
807 " -e typo3TestingRedisHost=redis4 \\\n" +
808 " -e typo3TestingMemcachedHost=memcached1-5 \\\n" +
809 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
810 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
811 " --rm \\\n" +
812 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
813 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
814 "}\n" +
815 "\n" +
816 "phpunit --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "UnitTests.xml"
817 )
818 )
819 .finalTasks(
820 this.getTaskStopDockerDependencies(),
821 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
822 .resultDirectories("test-reports/phpunit.xml")
823 )
824 .requirements(
825 this.getRequirementDocker10()
826 )
827 .cleanWorkingDirectory(true);
828 }
829
830 /**
831 * Jobs for unit testing PHP in random test order
832 *
833 * @param int numberOfRuns
834 * @param String requirementIdentfier
835 */
836 protected ArrayList<Job> getJobUnitPhpRandom(int numberOfRuns, String requirementIdentifier) {
837 ArrayList<Job> jobs = new ArrayList<Job>();
838
839 for (int i=0; i<numberOfRuns; i++) {
840 jobs.add(new Job("Unit " + requirementIdentifier + " random 0" + i, new BambooKey("UTR" + requirementIdentifier + "0" + i))
841 .description("Run unit tests on " + requirementIdentifier + " in random order 0" + i)
842 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
843 .tasks(
844 this.getTaskGitCloneRepository(),
845 this.getTaskGitCherryPick(),
846 this.getTaskComposerInstall(requirementIdentifier),
847 this.getTaskDockerDependenciesUnit(),
848 new ScriptTask()
849 .description("Run phpunit-randomizer")
850 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
851 .inlineBody(
852 this.getScriptTaskBashInlineBody() +
853 "function phpunitRandomizer() {\n" +
854 " docker run \\\n" +
855 " -u ${HOST_UID} \\\n" +
856 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
857 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
858 " -e typo3TestingRedisHost=redis4 \\\n" +
859 " -e typo3TestingMemcachedHost=memcached1-5 \\\n" +
860 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
861 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
862 " --rm \\\n" +
863 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
864 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit-randomizer $*\"\n" +
865 "}\n" +
866 "\n" +
867 "phpunitRandomizer --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "UnitTests.xml --order rand"
868 )
869 )
870 .finalTasks(
871 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
872 .resultDirectories("test-reports/phpunit.xml")
873 )
874 .requirements(
875 this.getRequirementDocker10()
876 )
877 .cleanWorkingDirectory(true)
878 );
879 }
880
881 return jobs;
882 }
883
884 /**
885 * Task definition for basic core clone of linked default repository
886 */
887 protected Task getTaskGitCloneRepository() {
888 return new VcsCheckoutTask()
889 .description("Checkout git core")
890 .checkoutItems(new CheckoutItem().defaultRepository());
891 }
892
893 /**
894 * Task definition to cherry pick a patch set from gerrit on top of cloned core
895 */
896 protected Task getTaskGitCherryPick() {
897 return new ScriptTask()
898 .description("Gerrit cherry pick")
899 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
900 .inlineBody(
901 this.getScriptTaskBashInlineBody() +
902 "CHANGEURL=${bamboo.changeUrl}\n" +
903 "CHANGEURLID=${CHANGEURL#https://review.typo3.org/}\n" +
904 "PATCHSET=${bamboo.patchset}\n" +
905 "\n" +
906 "if [[ $CHANGEURL ]]; then\n" +
907 " gerrit-cherry-pick https://review.typo3.org/Packages/TYPO3.CMS $CHANGEURLID/$PATCHSET || exit 1\n" +
908 "fi\n"
909 );
910 }
911
912 /**
913 * Task definition to execute composer install
914 *
915 * @param String requirementIdentifier
916 */
917 protected Task getTaskComposerInstall(String requirementIdentifier) {
918 return new ScriptTask()
919 .description("composer install")
920 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
921 .inlineBody(
922 this.getScriptTaskBashInlineBody() +
923 this.getScriptTaskComposer(requirementIdentifier) +
924 "composer install -n"
925 )
926 .environmentVariables(this.composerRootVersionEnvironment);
927 }
928
929 /**
930 * Task to prepare an acceptance test starting selenium and others
931 */
932 protected Task getTaskPrepareAcceptanceTest() {
933 return new ScriptTask()
934 .description("Start php web server, chromedriver, prepare environment")
935 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
936 .inlineBody(
937 this.getScriptTaskBashInlineBody() +
938 "php -n -c /etc/php/cli-no-xdebug/php.ini -S localhost:8000 >/dev/null 2>&1 &\n" +
939 "echo $! > phpserver.pid\n" +
940 "\n" +
941 "./bin/chromedriver --url-base=/wd/hub >/dev/null 2>&1 &\n" +
942 "echo $! > chromedriver.pid\n" +
943 "\n" +
944 "mkdir -p typo3temp/var/tests/\n"
945 );
946 }
947
948 /**
949 * Start docker sibling containers to execute functional tests on mariadb
950 */
951 protected Task getTaskDockerDependenciesFunctionalMariadb10() {
952 return new ScriptTask()
953 .description("Start docker siblings for functional tests on mariadb")
954 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
955 .inlineBody(
956 this.getScriptTaskBashInlineBody() +
957 "cd Build/testing-docker/bamboo\n" +
958 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
959 "docker-compose run start_dependencies_functional_mariadb10"
960 );
961 }
962
963 /**
964 * Start docker sibling containers to execute functional tests on mssql
965 */
966 protected Task getTaskDockerDependenciesFunctionalMssql() {
967 return new ScriptTask()
968 .description("Start docker siblings for functional tests on mssql")
969 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
970 .inlineBody(
971 this.getScriptTaskBashInlineBody() +
972 "cd Build/testing-docker/bamboo\n" +
973 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
974 "docker-compose run start_dependencies_functional_mssql"
975 );
976 }
977
978 /**
979 * Start docker sibling containers to execute functional tests on postgres
980 */
981 protected Task getTaskDockerDependenciesFunctionalPostgres95() {
982 return new ScriptTask()
983 .description("Start docker siblings for functional tests on postgres9-5")
984 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
985 .inlineBody(
986 this.getScriptTaskBashInlineBody() +
987 "cd Build/testing-docker/bamboo\n" +
988 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
989 "docker-compose run start_dependencies_functional_postgres9-5"
990 );
991 }
992
993 /**
994 * Start docker sibling containers to execute unit tests
995 */
996 protected Task getTaskDockerDependenciesUnit() {
997 return new ScriptTask()
998 .description("Start docker siblings for unit tests")
999 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1000 .inlineBody(
1001 this.getScriptTaskBashInlineBody() +
1002 "cd Build/testing-docker/bamboo\n" +
1003 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1004 "docker-compose run start_dependencies_unit"
1005 );
1006 }
1007
1008 /**
1009 * Stop started docker containers
1010 */
1011 protected Task getTaskStopDockerDependencies() {
1012 return new ScriptTask()
1013 .description("Stop docker siblings")
1014 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1015 .inlineBody(
1016 this.getScriptTaskBashInlineBody() +
1017 "cd Build/testing-docker/bamboo\n" +
1018 "docker-compose down -v"
1019 );
1020 }
1021
1022 /**
1023 * Task to split functional jobs into chunks
1024 */
1025 protected Task getTaskSplitFunctionalJobs(int numberOfJobs) {
1026 return new ScriptTask()
1027 .description("Create list of test files to execute per job")
1028 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1029 .inlineBody(
1030 this.getScriptTaskBashInlineBody() +
1031 "./" + this.testingFrameworkBuildPath + "Scripts/splitFunctionalTests.sh " + numberOfJobs
1032 );
1033 }
1034
1035 /**
1036 * Requirement for docker 1.0 set by bamboo-agents
1037 */
1038 protected Requirement getRequirementDocker10() {
1039 return new Requirement("system.hasDocker")
1040 .matchValue("1.0")
1041 .matchType(Requirement.MatchType.EQUALS);
1042 }
1043
1044 /**
1045 * A bash header for script tasks forking a bash if needed
1046 */
1047 protected String getScriptTaskBashInlineBody() {
1048 return
1049 "#!/bin/bash\n" +
1050 "\n" +
1051 "if [ \"$(ps -p \"$$\" -o comm=)\" != \"bash\" ]; then\n" +
1052 " bash \"$0\" \"$@\"\n" +
1053 " exit \"$?\"\n" +
1054 "fi\n" +
1055 "\n" +
1056 "set -x\n" +
1057 "\n";
1058 }
1059
1060 /**
1061 * A bash function aliasing 'composer' as docker command
1062 *
1063 * @param String requirementIdentifier
1064 */
1065 protected String getScriptTaskComposer(String requirementIdentifier) {
1066 return
1067 "function composer() {\n" +
1068 " docker run \\\n" +
1069 " -u ${HOST_UID} \\\n" +
1070 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1071 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1072 " -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} \\\n" +
1073 " -e HOME=${HOME} \\\n" +
1074 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1075 " --rm \\\n" +
1076 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1077 " bin/bash -c \"cd ${PWD}; composer $*\"\n" +
1078 "}\n" +
1079 "\n";
1080 }
1081 }