Show Menu
TOPICS×

Understanding the Build Environment

Build Environment Details

Cloud Manager builds and tests your code using a specialized build environment. This environment has the following attributes:
  • The build environment is Linux-based, derived from Ubuntu 18.04.
  • Apache Maven 3.6.0 is installed.
  • The Java versions installed are Oracle JDK 8u202 and 11.0.2.
  • There are some additional system packages installed which are necessary:
    • bzip2
    • unzip
    • libpng
    • imagemagick
    • graphicsmagick
  • Other packages may be installed at build time as described below .
  • Every build is done on a pristine environment; the build container does not keep any state between executions.
  • Maven is always run with the following three commands:
    • mvn --batch-mode org.apache.maven.plugins:maven-dependency-plugin:3.1.2:resolve-plugins
    • mvn --batch-mode org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean -Dmaven.clean.failOnError=false
    • mvn --batch-mode org.jacoco:jacoco-maven-plugin:prepare-agent packageco-maven-plugin:prepare-agent package
  • Maven is configured at a system level with a settings.xml file which automatically includes the public Adobe Artifact repository. (See Adobe Public Maven Repository for more details).
Although Cloud Manager does not define a specific version of the jacoco-maven-plugin , the version used must be at least 0.7.5.201505241946 .

Using Java 11 Support

Cloud Manager now supports building customer projects with both Java 8 and Java 11. By default, projects are built using Java 8.
Customers who want to use Java 11 in their projects can do so using the Apache Maven Toolchains Plugin .
To do this, in the pom.xml file, add a <plugin> entry that looks like this:
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-toolchains-plugin</artifactId>
    <version>1.1</version>
    <executions>
        <execution>
            <goals>
                <goal>toolchain</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <toolchains>
            <jdk>
                <version>11</version>
                <vendor>oracle</vendor>
           </jdk>
        </toolchains>
    </configuration>
</plugin>

Supported vendor values are oracle and sun and the supported version values are 1.8 , 1.11 , and 11 .
The Cloud Manager project build is still using Java 8 to invoke Maven, therefore checking or enforcing the Java version configured in the toolchain plugin through plugins like the Apache Maven Enforcer Plugin does not work and such plugins must not be used.

Environment Variables

Standard Environment Variables

In some cases, customers find it necessary to vary the build process based on information about the program or pipeline.
For example, if build-time JavaScript minification is being done, through a tool like gulp, there may be a desire to use a different minification level when building for a dev environment as opposed to building for stage and production.
To support this, Cloud Manager adds these standard environment variables to the build container for every execution.
Variable Name
Definition
CM_BUILD
Always set to "true"
BRANCH
The configured branch for the execution
CM_PIPELINE_ID
The numeric pipeline identifier
CM_PIPELINE_NAME
The pipeline name
CM_PROGRAM_ID
The numeric program identifier
CM_PROGRAM_NAME
The program name
ARTIFACTS_VERSION
For a stage or production pipeline, the synthetic version generated by Cloud Manager
CM_AEM_PRODUCT_VERSION
The Release name

Pipeline Variables

In some cases, a customer's build process may depend upon specific configuration variables which would be inappropriate to place in the Git repository or need to vary between pipeline executions using the same branch.
Cloud Manager allows for these variables to be configured through the Cloud Manager API or Cloud Manager CLI on a per-pipeline basis. Variables may be stored as either plain text or encrypted at rest. In either case, variables are made available inside the build environment as an environment variable which can then be referenced from inside the pom.xml file or other build scripts.
To set a variable using the CLI, run a command like:
$ aio cloudmanager:set-pipeline-variables PIPELINEID --variable MY_CUSTOM_VARIABLE test
Current variables can be listed:
$ aio cloudmanager:list-pipeline-variables PIPELINEID
Variable names may only contain alphanumeric and underscore (_) characters. By convention, the names should be all upper-case. There is a limit of 200 variables per pipeline, each name must be less than 100 characters and each value must be less than 2048 characters in the case of string type variables and 500 characters in the case of secretString type variables.
When used inside a Maven pom.xml file, it is typically helpful to map these variables to Maven properties using a syntax similar to this:
        <profile>
            <id>cmBuild</id>
            <activation>
                <property>
                    <name>env.CM_BUILD</name>
                </property>
            </activation>
            <properties>
                <my.custom.property>${env.MY_CUSTOM_VARIABLE}</my.custom.property> 
            </properties>
        </profile>

Installing Additional System Packages

Some builds require additional system packages to be installed to function fully. For example, a build may invoke a Python or ruby script and, as a result, need to have an appropriate language interpreter installed. This can be done by calling the exec-maven-plugin to invoke APT. This execution should generally be wrapped in a Cloud Manager-specific Maven profile. For example, to install python:
        <profile>
            <id>install-python</id>
            <activation>
                <property>
                        <name>env.CM_BUILD</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.6.0</version>
                        <executions>
                            <execution>
                                <id>apt-get-update</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>apt-get</executable>
                                    <arguments>
                                        <argument>update</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>install-python</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>apt-get</executable>
                                    <arguments>
                                        <argument>install</argument>
                                        <argument>-y</argument>
                                        <argument>--no-install-recommends</argument>
                                        <argument>python</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

This same technique can be used to install language specific packages, i.e. using gem for RubyGems or pip for Python Packages.
Installing a system package in this manner does not install it in the runtime environment used for running Adobe Experience Manager. If you need a system package installed on the AEM environment, contact your Adobe Representative.