V2 Builds and Artifacts
This topic describes how the V2 Pipelines build and reuse Self-Managed Commerce artifacts.
Overview
The main Commerce build job in the new V2 pipelines is v2-build-commerce-images. You run this job to build the Commerce images, the base images, and third-party images such as ActiveMQ and MySQL. Parameters in the job allow you to control which images get built.
The default image tag used is a short hash of the ep-commerce Git commit that is being built. When you run the job and specify a branch to build, such as main, the job will identify the exact Git commit after it checks out the branch. Every build phase in the build process uses that same commit, even if a new commit is pushed to the branch after the build job has started.
The V2 build chain is image-based. The v2-build-commerce-images job checks if the ep-commerce code for that exact commit has been previously built. If not, it calls the v2-build-commerce-maven-artifacts job, which builds the code and pushes a commerce-maven-artifacts image containing the built source tree. The v2-build-commerce-images job consumes that image and uses it to build the container images. Note that the new build process, unlike the older process, does not build or use the Commerce deployment package.
If you rerun v2-build-commerce-images for an ep-commerce commit that was previously built, and any of the images already exist, by default the job will not rebuild those images. The job checks if an image already exists and, if it does, will skip building it to save time and resources. You can override this by setting the forceRebuildImages parameter.
Build and Deploy Workflow
At a high level, the flow is:
- Run the
v2-build-commerce-imagesjob to build the base images, ActiveMQ and MySQL container images, and the Self-Managed Commerce application images.- This will call the
v2-build-commerce-maven-artifactsjob if the requiredcommerce-maven-artifactsimage does not yet exist, but will skip building it if it already exists.
- This will call the
- Run any desired test jobs, such as extension tests and Cortex system tests. They will also find and reuse the compiled artifacts
commerce-maven-artifactsimage. - Run the
v2-deploy-commerce-imagesjob to deploy the new Commerce images to an existing Commerce environment. With this job you may optionally re-tag the images before deploying, or optionally run data-pop if required.
Image Source and Contents
All of the inputs that affect the contents of the images are from the specified ep-commerce branch. Your application development team controls the contents and configuration of the images by modifying files in the ep-commerce application code. To learn more, see Self-Managed Commerce Build Tools in the Self-Managed Commerce documentation.
V2 Build Jobs
More detail about the build jobs is below.
v2-build-commerce-maven-artifacts
This job checks out the Self-Managed Commerce source code at a specific commit, performs the Maven build, removes the Maven settings file, and publishes the resulting image as jenkins/commerce-maven-artifacts:<tag>. The Maven settings file is removed because it typically includes credentials that should not be baked into images for security reasons.
The image contains:
- The Self-Managed Commerce source code at
/opt/ep-commerce. - The Maven local repository under
/root/.m2/repository/. - The build tools (Java, Maven, Ansible) needed by downstream jobs.
The default image tag is the ep-commerce project's short commit hash.
This is the key reusable artifact in the V2 model.
v2-build-commerce-images
This job uses the commerce-maven-artifacts image to build the base images and Self-Managed Commerce application images, including:
ep/cortexep/cmep/searchep/batchep/integrationep/data-syncep/data-pop-toolep/mockep/info-page
The default image tag for the Commerce images is the ep-commerce project's short commit hash.
This job also builds the base and third-party images:
ep/amazonlinux-javaep/tomcatep/activemqep/mysql
Self-Managed Commerce patch releases update the software versions in these images, including the operating system base image. Rebuild these images when you consume Self-Managed Commerce patches. For more information, see Update Self-Managed Commerce Images.
The job parameters give you extensive control over the job's behavior, including which images to build and what image tags to use.
What Changed Compared to the Legacy Build Flow
In the legacy flow, build and test jobs often rebuilt Maven artifacts from source as part of each job run.
In the V2 flow:
- Maven artifacts are built once for a specific commit.
- Downstream jobs reuse the
commerce-maven-artifactsimage. - The application image job builds the container layout, not the older deployment package.
- No dependency on the Elastic Path Docker project.
- Test jobs use the same built artifacts that the image jobs use.
- Self-Managed Commerce base and application container images are built on one
commerce-maven-artifactspod, maximizing reuse and eliminating the repeated push and pull of base images. Theep/info-pageimage is built separately on the lightweight docker agent.
How the Test Jobs Reuse Built Artifacts
v2-run-extensions-tests
This job uses the commerce-maven-artifacts image to run extension tests against the already-built artifacts.
v2-run-cortex-system-tests
This job also uses the commerce-maven-artifacts image, but it runs against a deployed environment after the V2 deployment flow has finished.
The important difference from older test jobs is that these V2 jobs do not rebuild the Self-Managed Commerce source tree before testing.
v2-commerce-branch-validation
The v2-commerce-branch-validation job ties the V2 workflow together for temporary validation environments.
At a high level it:
- Resolves the requested Git ref to a commit hash.
- Tags the generated images with that commit.
- Builds
commerce-maven-artifacts. - Runs
v2-run-extensions-testsin parallel with the deployment chain. - Builds base and application images.
- Deploys a temporary environment.
- Runs Cortex system tests.
- Destroys the temporary environment.
Benefits
The v2-commerce-branch-validation design provides several practical benefits:
- Fewer repeated Maven builds.
- Faster re-runs when tagged images already exist.
- No dependency on the Elastic Path Docker project.
- The ability to easily tune the Commerce environment configuration, with the provided component templates in
environments/branch-validation-template/.
For information about the deployment side of the V2 approach, see Configuring Environments with V2 Pipelines.