Skip to content

Commit

Permalink
#6 Triggering child builds with parent branch
Browse files Browse the repository at this point in the history
  • Loading branch information
presidentio committed Aug 19, 2017
1 parent 6cb7602 commit c5f4fd6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 0 additions & 4 deletions README.md
Expand Up @@ -56,10 +56,6 @@ If you don't want to use you credentials - create new user and grant him permiss
This inconvenience will be removed as soon as build user [will have required permissions](https://youtrack.jetbrains.com/issue/TW-39206).
At this point you have configured build.

#####Vcs Revision
If you want to guarantee that each child build will be run with the same source revision, you need to attache both build configurations to the same vcs root.
In this case build revision will be promoted from parent build to all child.

### Viewing Results
You can look at child builds list at *Matrix build* tab on build page.
There are listed finished, running and queued builds with there parameters.
Expand Down
Expand Up @@ -34,6 +34,7 @@
public class MatrixBuildProcess implements BuildProcess, Runnable {

private static final Logger LOGGER = Loggers.AGENT;
public static final String BRANCH_CONFIG = "teamcity.build.branch";

private ObjectMapper objectMapper = new ObjectMapper();
private Thread processThread;
Expand Down Expand Up @@ -105,7 +106,7 @@ public void run() {
}

List<QueuedBuild> builds = new ArrayList<>();
BuildPlan buildPlan = new BuildPlan(configuration);
BuildPlan buildPlan = new BuildPlan(configuration, getBranch());
for (PlannedBuild plannedBuild : buildPlan.getBuilds()) {
builds.add(plannedBuild.startBuild(buildQueueResource, buildsResource,
buildRunnerContext.getBuild().getBuildLogger()));
Expand Down Expand Up @@ -161,4 +162,8 @@ private void saveReport(Report report) throws IOException {
artifactsWatcher.addNewArtifactsPath(reportFile.getAbsolutePath() + " => " + PluginConst.REPORT_DIRECTORY);
}

private String getBranch() {
return buildRunnerContext.getConfigParameters().get(BRANCH_CONFIG);
}

}
Expand Up @@ -19,8 +19,10 @@
public class BuildPlan {

private List<PlannedBuild> builds = new ArrayList<>();
private String branch;

public BuildPlan(MatrixBuildConfiguration configuration) {
public BuildPlan(MatrixBuildConfiguration configuration, String branch) {
this.branch = branch;
init(configuration);
}

Expand Down Expand Up @@ -106,15 +108,12 @@ private Build createBuild(String buildTypeId, Integer buildNumber, Map<String, S
tags.getTag().add(tag);
build.setTags(tags);

enrichWithRevision(build);
//set branch
build.setBranchName(branch);

return build;
}

private void enrichWithRevision(Build build) {
//TODO: implement
}

public List<PlannedBuild> getBuilds() {
return builds;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -8,7 +8,7 @@
<packaging>pom</packaging>

<properties>
<teamcity.version>9.0.1</teamcity.version>
<teamcity.version>9.1.6</teamcity.version>
<java.version>1.7</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
Expand Down

0 comments on commit c5f4fd6

Please sign in to comment.