75137ceb0923e4804123700a35531f4f4792ed58
[Packages/TYPO3.CMS.git] / Build / bamboo / src / main / java / core / PreMergeSpec.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.BambooSpec;
19 import com.atlassian.bamboo.specs.api.builders.AtlassianModule;
20 import com.atlassian.bamboo.specs.api.builders.BambooKey;
21 import com.atlassian.bamboo.specs.api.builders.Variable;
22 import com.atlassian.bamboo.specs.api.builders.notification.AnyNotificationRecipient;
23 import com.atlassian.bamboo.specs.api.builders.notification.Notification;
24 import com.atlassian.bamboo.specs.api.builders.plan.Job;
25 import com.atlassian.bamboo.specs.api.builders.plan.Plan;
26 import com.atlassian.bamboo.specs.api.builders.plan.Stage;
27 import com.atlassian.bamboo.specs.api.builders.plan.branches.BranchCleanup;
28 import com.atlassian.bamboo.specs.api.builders.plan.branches.PlanBranchManagement;
29 import com.atlassian.bamboo.specs.api.builders.plan.configuration.AllOtherPluginsConfiguration;
30 import com.atlassian.bamboo.specs.api.builders.project.Project;
31 import com.atlassian.bamboo.specs.builders.notification.PlanCompletedNotification;
32 import com.atlassian.bamboo.specs.builders.task.ScriptTask;
33 import com.atlassian.bamboo.specs.builders.trigger.RemoteTrigger;
34 import com.atlassian.bamboo.specs.builders.trigger.RepositoryPollingTrigger;
35 import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties;
36 import com.atlassian.bamboo.specs.util.BambooServer;
37 import com.atlassian.bamboo.specs.util.MapBuilder;
38
39 /**
40 * Core 7.6 pre-merge test plan.
41 */
42 @BambooSpec
43 public class PreMergeSpec extends AbstractCoreSpec {
44
45 protected static String planName = "Core 7.6 pre-merge";
46 protected static String planKey = "GTC76";
47
48 protected int numberOfFunctionalMysqlJobs = 5;
49
50 /**
51 * Run main to publish plan on Bamboo
52 */
53 public static void main(final String[] args) throws Exception {
54 // By default credentials are read from the '.credentials' file.
55 BambooServer bambooServer = new BambooServer(bambooServerName);
56 bambooServer.publish(new PreMergeSpec().createPlan());
57 bambooServer.publish(new PreMergeSpec().getDefaultPlanPermissions(projectKey, planKey));
58 }
59
60 /**
61 * Core 7.6 pre-merge plan is in "TYPO3 core" project of bamboo
62 */
63 Project project() {
64 return new Project().name(projectName).key(projectKey);
65 }
66
67 /**
68 * Returns full Plan definition
69 */
70 Plan createPlan() {
71 // PREPARATION stage
72 ArrayList<Job> jobsPreparationStage = new ArrayList<Job>();
73
74 jobsPreparationStage.add(this.getJobBuildLabels());
75
76 jobsPreparationStage.add(this.getJobComposerValidate());
77
78 Stage stagePreparation = new Stage("Preparation")
79 .jobs(jobsPreparationStage.toArray(new Job[jobsPreparationStage.size()]));
80
81 // MAIN stage
82 ArrayList<Job> jobsMainStage = new ArrayList<Job>();
83
84 jobsMainStage.add(this.getJobIntegrationVarious());
85
86 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(this.numberOfFunctionalMysqlJobs, this.getRequirementPhpVersion55(), "PHP55"));
87 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(this.numberOfFunctionalMysqlJobs, this.getRequirementPhpVersion56(), "PHP56"));
88 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(this.numberOfFunctionalMysqlJobs, this.getRequirementPhpVersion70(), "PHP70"));
89 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(this.numberOfFunctionalMysqlJobs, this.getRequirementPhpVersion71(), "PHP71"));
90
91 jobsMainStage.add(this.getJobLintPhp(this.getRequirementPhpVersion55(), "PHP55"));
92 jobsMainStage.add(this.getJobLintPhp(this.getRequirementPhpVersion56(), "PHP56"));
93 jobsMainStage.add(this.getJobLintPhp(this.getRequirementPhpVersion70(), "PHP70"));
94 jobsMainStage.add(this.getJobLintPhp(this.getRequirementPhpVersion71(), "PHP71"));
95
96 jobsMainStage.add(this.getJobUnitPhp(this.getRequirementPhpVersion55(), "PHP55"));
97 jobsMainStage.add(this.getJobUnitPhp(this.getRequirementPhpVersion56(), "PHP56"));
98 jobsMainStage.add(this.getJobUnitPhp(this.getRequirementPhpVersion70(), "PHP70"));
99 jobsMainStage.add(this.getJobUnitPhp(this.getRequirementPhpVersion71(), "PHP71"));
100
101 Stage stageMainStage = new Stage("Main stage")
102 .jobs(jobsMainStage.toArray(new Job[jobsMainStage.size()]));
103
104 // Compile plan
105 return new Plan(project(), planName, planKey)
106 .description("Execute TYPO3 core 7.6 pre-merge tests. Auto generated! See Build/bamboo of core git repository.")
107 .pluginConfigurations(this.getDefaultPlanPluginConfiguration())
108 .stages(
109 stagePreparation,
110 stageMainStage
111 )
112 .linkedRepositories("git.typo3.org Core 7.6")
113 .triggers(
114 new RepositoryPollingTrigger()
115 .name("Repository polling for post-merge builds"),
116 new RemoteTrigger()
117 .name("Remote trigger for pre-merge builds")
118 .description("Gerrit")
119 .triggerIPAddresses("5.10.165.218,91.184.35.13"))
120 .variables(
121 new Variable("changeUrl", ""),
122 new Variable("patchset", "")
123 )
124 .planBranchManagement(
125 new PlanBranchManagement()
126 .delete(new BranchCleanup())
127 .notificationForCommitters()
128 )
129 .notifications(new Notification()
130 .type(new PlanCompletedNotification())
131 .recipients(new AnyNotificationRecipient(new AtlassianModule("com.atlassian.bamboo.plugins.bamboo-slack:recipient.slack"))
132 .recipientString("https://intercept.typo3.com/index.php")
133 )
134 );
135 }
136
137 /**
138 * Job creating labels needed for intercept communication
139 */
140 protected Job getJobBuildLabels() {
141 return new Job("Create build labels", new BambooKey("CLFB"))
142 .description("Create changeId and patch set labels from variable access and parsing result of a dummy task")
143 .pluginConfigurations(new AllOtherPluginsConfiguration()
144 .configuration(new MapBuilder()
145 .put("repositoryDefiningWorkingDirectory", -1)
146 .put("custom", new MapBuilder()
147 .put("auto", new MapBuilder()
148 .put("regex", "https:\\/\\/review\\.typo3\\.org\\/(#\\/c\\/)?(\\d+)")
149 .put("label", "change-\\2\\, patchset-${bamboo.patchset}")
150 .build()
151 )
152 .put("buildHangingConfig.enabled", "false")
153 .put("ncover.path", "")
154 .put("clover", new MapBuilder()
155 .put("path", "")
156 .put("license", "")
157 .put("useLocalLicenseKey", "true")
158 .build()
159 )
160 .build()
161 )
162 .build()
163 )
164 )
165 .tasks(
166 new ScriptTask()
167 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
168 .inlineBody("echo \"I'm just here for the labels!\"")
169 )
170 .cleanWorkingDirectory(true);
171 }
172 }