Skip to content

Commit

Permalink
[NCL-5530] Support pig metadata, build memory
Browse files Browse the repository at this point in the history
  • Loading branch information
thescouser89 committed Jun 4, 2020
1 parent 34a1569 commit 28820eb
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -65,13 +68,23 @@ public class BuildConfig {
private String description;
private String environmentId;

/**
* build pod memory in GB
*/
private Integer buildPodMemory;
private String pigYamlMetadata;

private Set<String> customPmeParameters = new TreeSet<>();
private Set<String> extraRepositories = new TreeSet<>();
private String executionRoot;

private List<String> dependencies = new ArrayList<>();
private Set<String> alignmentParameters = new TreeSet<>();
private Boolean branchModified;

/**
* Set the defaults of buildConfig if not explicitly specified
*
* <p>
* If buildType is not specified in the buildConfig or in the defaults, it is set to MVN
*
* @param defaults
Expand Down Expand Up @@ -142,6 +155,11 @@ private boolean urlsEqual(SCMRepository repo) {

@JsonIgnore
public Map<String, String> getGenericParameters(BuildConfiguration oldConfig, boolean forceRebuild) {

if (!customPmeParameters.isEmpty() && alignmentParameters.isEmpty()) {
log.warn("[Deprecated] Please rename 'customPmeParameters' section to 'alignmentParameters'");
alignmentParameters = customPmeParameters;
}
Map<String, String> result = new HashMap<>();

String oldForceValue = oldConfig == null ? "" : oldConfig.getParameters().getOrDefault(BUILD_FORCE, "");
Expand All @@ -152,6 +170,29 @@ public Map<String, String> getGenericParameters(BuildConfiguration oldConfig, bo
result.put("ALIGNMENT_PARAMETERS", dependencyExclusions);
result.put(BUILD_FORCE, forceValue);

if (buildPodMemory != null) {
result.put("BUILDER_POD_MEMORY", buildPodMemory.toString());
}

if (pigYamlMetadata != null) {
String metadata = "";
try {
metadata = URLDecoder.decode(pigYamlMetadata, StandardCharsets.UTF_8.toString());
} catch (UnsupportedEncodingException ex) {
metadata = pigYamlMetadata;
}
result.put("PIG_YAML_METADATA", metadata);
}

if (executionRoot != null) {
result.put("EXECUTION_ROOT_NAME", executionRoot);
}

if (!extraRepositories.isEmpty()) {
String repositoriesAsString = String.join("\\n", extraRepositories);
result.put("EXTRA_REPOSITORIES", repositoriesAsString);
}

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ private SCMRepository createRepository(BuildConfig buildConfig) {
try {
// todo: does it work with the external urls?
RepositoryCreationResponse response = repoClient.createNew(createRepoRequest);

SCMRepository repository = response.getRepository();
if (repository != null) {
return repository;
Expand Down
104 changes: 104 additions & 0 deletions test/build-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
###############################################################################
# Variable definition in the format :
# #!<variableName>=<value>
#
# Variables can be used anywhere in the YAML file in the format :
#
# example :
#
#!version=7.1.0
#!milestone=DR1
###############################################################################


###############################################################################
# Product section
###############################################################################
product:
name: ProductB # full product name
abbreviation: testb # official product name abbreviation - used to create the brew/koji tag name
stage: Alpha1 # product phase, if we're targetting GA, should be GA, etc
issueTrackerUrl: http://issues.jboss.org/browse/TEST
version: 1.2.0

###############################################################################
# version of the product, PNC will use <major>.<minor> (in this case 7.1) as the product version
# and prepend the <micro> to the milestone name
#
# Example values are DR1, ER2, CR1
#
# It is also possible to use have an auto-incremented milestone number.
# To achieve it, use an asterisk in the place of milestone number, e.g. ER*
# The auto-incremented milestone requires -releaseStorageUrl option
###############################################################################
milestone: ER1
group: ProductA 1.2 all # name of the PNC build group

###############################################################################
# build configurations. If there are some properties that are shared among most of the configurations
# they can be defined in defaultBuildParameters. For a complete list of available properties, take a look at BuildConfig class.
###############################################################################
defaultBuildParameters:
project: my-project # name of the project to assign the configuration to
environmentId: 1 # PNC environment ID. You can list available environments with `bacon pnc environment list`
buildScript: mvn clean deploy -DskipTests -B
buildType: GRADLE

builds:
- name: my-app-a-7.1
buildScript: mvn clean install -DskipTests=true # overriden build script
externalScmUrl: https://github.com/janinko/empty.git
scmRevision: master
dependencies:
- my-app-b-7.2

- name: my-app-b-7.3
project: my-other-project
externalScmUrl: https://github.com/pkocandr/empty.git
scmRevision: master

# ###############################################################################
# # after the builds are done, the deliverables are prepared.
# # the following sections configure deliverables preparation
# ###############################################################################
outputPrefixes:
releaseFile: product-a # prefix for the deliverables. Version and milestone will be appended to it
releaseDir: product-a # prefix for a top level directory name inside the deliverables
# flow:
# licensesGeneration:
# strategy: GENERATE
# repositoryGeneration:
# strategy: DOWNLOAD # it's also possible to generate them, see below for an examlpe config

# # an artifact which filename matches .*maven-repository\.zip produced by my-app-a-7.1 build will be used as a base
# # of the repository generation
# sourceBuild: my-app-a-7.1
# sourceArtifact: '.*maven-repository\.zip'

# # Add artifacts from given builds to the repository zip
# # The expression is matched against the PNC identifier for the file.
# additionalArtifacts:
# - from: 'my-app-a-7.1'
# download:
# - '^my.groupId:my-artifact-id:jar:7.1.0.redhat-\d\d:sources'
# - from: 'my-app-b-7.1'
# download:
# - 'org.eclipse.aether:aether-util:jar:1.0.0.v20140518-redhat-\d\d:sources'

# # add artifacts from outside the current builds to the repository zip.
# # Note this section requires exact groupId:artifactId:packaging:version or groupId:artifactId:packaging:version:classifier
# externalAdditionalArtifacts:
# - 'org.jboss.eap:wildfly-ejb-client-bom:pom:7.1.1.GA-redhat-2'
# javadocGeneration:
# strategy: DOWNLOAD # another option is IGNORE
# sourceBuild: 'my-app-a-7.1'
# sourceArtifact: '.*javadoc\.zip'

# ###############################################################################
# # a place to define product-specific add-ons.
# # Add ons have to extend AddOn and be registered in AddOnFactory.
# ###############################################################################
# addons:
# addOnName:
# addOnConfigProperty:
# add on configuration

0 comments on commit 28820eb

Please sign in to comment.