Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Setting Up the Continuous Integration (CI) Server

Setting Up the Continuous Integration (CI) Server

Note: Role: DevOps
Dependent on By Documentation
CI server provisioning IT Operations Prepare Infrastructure
Maven repository setup DevOps Setup Maven Repository
Source code preparation Tech Lead Prepare Source Code

Overview

This page provides instructions to create a working Continuous Integration server that builds and deploys Elastic Path projects. A Continuous Integration (CI) server is a core requirement for team-based development. Elastic Path recommends Jenkins.

The objectives of this step are to:

  • Automatically build all modules that were committed to source control in Preparing Elastic Path Source Code.
  • Deploy the resulting artifacts to the Maven repository manager.

Continuous Integration Jobs

This section provides descriptions on the continous integration jobs and associated commands. Setup continuous integration jobs only on the primary development branch. Automate the following jobs and associated commands:

Job Name Description Maven command
Elastic Path Commerce Builds the ep-commerce module and all modules within the ep-commerce module. This job builds:
  • Bill of Materials
  • Commerce Engine
  • Health Monitoring
  • Commerce Manager
  • Cortex Resources
  • Extensions
  • Commerce Data
  • Deployment Package

Root POM: ep-commerce/pom.xml

mvn -B -U -e clean deploy -Pwith-deployment-package
Deploy to Development Team Server

Root POM: ep-commerce/devops/pom.xml

mvn -B -U -e clean package

After Maven completes, the continuous integration server can execute the following script:

ssh $DEPLOYER_USER@$DEPLOYER_HOST """
cd ~/
rm -rf target &&
rm -rf deploy &&
mkdir deploy
"""

scp $WORKSPACE/pusher-package/target/*.zip $DEPLOYER_USER@$DEPLOYER_HOST:deploy

ssh $DEPLOYER_USER@$DEPLOYER_HOST """
cd deploy
chmod +x *.zip &&
unzip *pusher-package*.zip
"""

ssh $DEPLOYER_USER@$DEPLOYER_HOST """
cd deploy/the-pusher*
chmod +x PushDeploy.sh && ./PushDeploy.sh -p ../*deployment-package*.zip -f ../environments/dev/pusher.conf 
-f ../environments/dev/database.properties -d $DATA_POPULATION_COMMAND
"""           

the continuous integration job supplies the following parameters:

Parameter Description
$WORKSPACE The devops project directory on the continuous integration server.
$DEPLOY_ENVIRONMENT The environment to be deployed.
$DEPLOYER_HOST The host where the deployment script is run.
$DEPLOYER_USER The username for connecting to the deployer host.
$DATA_POPULATION_COMMAND The data population command to execute. Values are:
  • reset-db: Drops the database if it exists, then creates and populates a new database.
  • update-db: Updates the current database with schema and data changes.
  • none: Deploys without running data population.
Commerce Manager System Tests
  • Runs Commerce Manager Selenium + Cucumber tests using a deployed server as the test target.

Root POM: ep-commerce/extensions/cm/system-tests/selenium/pom.xml

mvn clean verify -Premote -Dcucumber.options="--tags @smoketest" -Dfailsafe.fork.count="1"
-Dremote.web.driver.url="http://<targetHost>:4444/wd/hub"
Tip: Enable Test-ids on the target server using JVM parameter -Dorg.eclipse.rap.rwt.enableUITests=true.
Cortex System tests
  • Runs Cortex Cucumber testing using a deployed server as the test target.
Root POM: ep-commerce/extensions/cortex/system-tests/cucumber/pom.xml
mvn -B -U -e clean verify -P
!setup-local-integration-test -
Dep.rest.baseurl=http://<cortex_host>/cortex -
Dep.jms.url=tcp://${activemq_host}:61616 -Dit.test=CucumberRunnerIT

Notes

  • Build modules with a valid settings.xml file. The recommended practice is to use the maven/ci-settings.xml file in the ep-commerce/devops module and check this out from SCM at the beginning of each job.
  • You can choose to add the following profiles to each of the Maven commands:
    1. pass-build-even-if-tests-fail: Using Jenkins, if a test fails then the build does not fail. This is useful because the build continues running and it will find all test failures. The build will turn unstable instead of passing or failing.
    2. pass-build-even-if-code-compliance-fails: Use the same logic as (1) but with regards to code compliance and code checking rules.

Distribution Management

This section provides information on the distrution management for Elastic Path projects. To deploy artifacts to your Maven repository you need a settings.xml file with the repository URLs and credentials to match the distribution management defined for Elastic Path projects, as shown below:

Note:

The <distributionManagement> element is defined as follows:

    <distributionManagement>
        <repository>
            <id>ep-releases</id>
            <url>${ep.releases.repository.url}</url>
        </repository>
        <snapshotRepository>
            <id>ep-snapshots</id>
            <url>${ep.snapshots.repository.url}</url>
        </snapshotRepository>
    </distributionManagement>

Updating the ci-settings.xml File

This section provides details to configure Maven for continuous integration builds and distribution management. Replace the following tokens in devops/maven/ci-settings.xml and commit to source control.

Token Description
PROJECT_REPOSITORY_GROUP_URL The URL of the project repository group used as the project mirror.
PROJECT_RELEASE_REPOSITORY_URL The URL of the project Elastic Path Releases Repository.
PROJECT_SNAPSHOT_REPOSITORY_URL The URL of the project Elastic Path Snapshots Repository.
MAVEN_DEPLOYER_USER_NAME The user name for the deployment Maven repository account.
MAVEN_DEPLOYER_PASSWORD

The password for the deployment Maven repository account.

Note:

See the Maven How to encrypt server passwords if you wish to use encrypted passwords in your ci-settings.xml.

Deliverables

  • A working Continuous Integration server that builds and deploys Elastic Path projects.