Example of manual Continuous Integration and Deployment with Maven commands - 7.2

Talend Software Development Life Cycle Best Practices Guide

Talend Big Data
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Administration Center
Talend Artifact Repository
Talend CommandLine
Talend JobServer
Talend Studio
Administration and Monitoring
Design and Development
If you do not use a Continuous Integration server like Jenkins or Azure, you can still perform some CI tasks by using the Maven commands compatible with the Talend products.

Main Maven options you may need to build your project manually

Maven option Description
-f, --file<arg> Forces the use of a specific POM file (here, the directory of the pom.xml of your Talend project).
-s, --settings<arg> Forces the use of a specific user settings file (here, the path to your custom settings.xml file).
-fn, --fail-never With this option, the build will never fail regardless of the project build result.

This option is useful when building multi-module projects.

-e, --erros Produces execution error messages.

This option is useful to diagnose an error in a Maven plugin.

-pl,--projects <arg> Comma-delimited list of specified reactor projects to build instead of all projects.
-am,--also-make If you have specified a project using the -pl command, also builds the projects required by the listed project(s).
-amd,--also-make-dependants If you have specified a project using the -pl command, also builds the projects that depend on the listed project(s).
-D,--define <arg> Defines a system property.

All Talend custom Maven options need to be used with the -D option. Check the list of these custom options in Talend custom Maven build options.

All Maven CLI options are referenced on the Apache Maven website.

Retrieving your custom Maven settings file

The first step before building your project manually is to retrieve the settings.xml file, save it and adapt it to your environment.

  1. Retrieve the settings.xml file from the Downloads tab in the left panel of this page.
  2. Adapt the file to your environment by replacing the parameter values (Nexus or Artifactory URLs, host names, ports, credentials, etc.) and save your changes.
    Tip: Look for the XXX references in the file provided as an example and replace them with values corresponding to your environment. This example file is adapted for Nexus. If you are using another artifact repository like Artifactory, you need to adapt this example to your repository URLs.
  3. Store this file in the directory of your choice. The path to this file will be used in the Maven command at build time.

Choosing the Maven build phase

You only need to learn a small set of commands to build any Maven project, and the pom.xml file will ensure you get the expected results. Each build phase represents a stage in the lifecycle, here are the ones that you may need:

  • test - test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
  • package - takes the compiled code and package it in its distributable format, such as a JAR.
    Note: If you want to exclude Java code from the generated zip file when using the package maven goal, add the !include-java-sources parameter as follows:
    mvn clean package -P !include-java-sources
  • install - installs the package into the local repository, for use as a dependency in other projects locally
  • deploy - done in the build environment, copies the final package to the remote repository for sharing with other developers and projects.

For more information on the Maven phases, see the Maven documentation.

Defining the Maven options to build your project

You have the possibility to adapt the Maven build command to fit your deployment needs. Here are some examples of commands:

  • To build, test, package artifacts of the CICD project as .jar or .zip files and deploy them to the Nexus snapshots repository :
    options: '-f <ProjectName>/poms/pom.xml -s <PathToDirectory>/settings.xml -Dlicense.path=<PathToDirectory>/license -Dupdatesite.path=<updatesiteURL> -DaltDeploymentRepository=snapshots::default::http://XXX:8081/repository/snapshots/ -fn -e'
    goals: 'deploy'


    options: '-f CICD/poms/pom.xml -s /home/talend/CI_dir/settings.xml -Dlicense.path=/home/talend/talend_studio/license -Dupdatesite.path=http://company/updatesite -DaltDeploymentRepository=snapshots::default::http://nexus:8081/repository/snapshots/ -fn -e'
    goals: 'deploy'
  • To build, clean, test, package artifacts of the CICD project as .jar or .zip files and deploy them to a Docker registry :
    options: '-f <ProjectName>/poms/pom.xml -s <PathToDirectory>/settings.xml -Dlicense.path=<PathToDirectory>/license -Dupdatesite.path=<updatesiteURL> -Ddocker.push.registry=<DockerRegistryName> -Ddocker.push.username=<Dockerusername> -Ddocker.push.password=<DockerPassword> -Dtalend.docker.name=<DockerImageName> -Xms1024m -Xmx3096m'
    goals: 'clean deploy'


    options: '-f CICD/poms/pom.xml -s /home/talend/CI_dir/settings.xml -Dlicense.path=/home/talend/talend_studio/license -Dupdatesite.path=http://company/updatesite -Ddocker.push.registry=registry.example.com/group/project -Ddocker.push.username=TalendUser -Ddocker.push.password=V3ryCompl3xPwd -Dtalend.docker.name=cicd4talend -Xms1024m -Xmx3096m'
    goals: 'clean deploy'

Installing a patch

If you need to install a patch (Talend Studio p2 patch, manual patch, component patch, etc.), you can use the -Dpatch.path option at build time.

Example for patches installed locally:
options: '-f CICD/poms/pom.xml -s /home/talend/CI_dir/settings.xml -Dlicense.path=/home/talend/talend_studio/license -Dpatch.path=D:/patches/Patch_TPS-2222.zip,D:/patches/Patch_TPS-3333.zip'
goals: 'package'