Adapting the script parameters to your environment - 7.2

Talend Software Development Life Cycle Best Practices Guide

EnrichVersion
7.2
EnrichProdName
Talend Big Data
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
EnrichPlatform
Talend Administration Center
Talend Artifact Repository
Talend CommandLine
Talend JobServer
Talend Studio
task
Administration and Monitoring
Deployment
Design and Development

Configure the pipeline script provided by Talend to generate the project items according to the Maven phase you want to achieve and the repository you want to deploy your artifacts to.

Some parameters come from the settings file you have previously defined and the credentials you have stored in Jenkins. For more information about the Talend Maven parameters you can use when configuring your pipeline, see Talend custom Maven build options.

Procedure

  1. Open the Talend_Pipeline configuration page and go to the Script editor.
  2. Set your own values for the environment variables defined at the top of the script (project name, Job name/version/type, repository URL, etc.).
    Tip: Look for the XXX references in the script provided by Talend as an example and replace them with values corresponding to your environment.

    The script can be found in the Downloads tab in the left panel of this page.

    Example

    Example of a project named CICD, a Job named job_feature956 with a 0.1 version and a Docker image named cicd4talend:
    env.PROJECT_GIT_NAME = 'CICD'
    env.PROJECT_NAME = env.PROJECT_GIT_NAME.toLowerCase()
    env.ARTIFACT = 'job_feature956'
    env.VERSION = '0.1'
    env.GIT_URL = 'https://github.com/talend/myrepo.git'
    env.TYPE = "" // if big data = _mr
    env.UPDATESITE_URL 'http://localhost:8080/P2/'
    env.IMAGE_NAME = 'cicd4talend'
    env.GIT_CREDENTIALS_ID = 'git'
    env.DOCKER_CREDENTIALS_ID = 'docker'

    If you are using a referenced project, you might need to adapt your pipeline script accordingly.

    Warning: Syntax requirements:
    • The value of the env.PROJECT_GIT_NAME variable must be in upper case otherwise it might cause build failure. If you used special characters in the project name or have any doubts on its final syntax you can check it in the parent pom.xml file of your project (talend.project.name variable in <project>/poms/pom.xml).
    • The value of the env.ARTIFACT variable must be in lower case even if the original name of your Job/Route/Service contained upper case as all artifacts are in lower case in the .pom files required to launch the build.
    • Do not add manually the "-SNAPSHOT" suffix to the version value. Snapshots and releases are decoupled from the version itself and must only be handled via the Studio preferences, see Changing the deployment version of each artifact at once.
  3. To define the repository in which you want to deploy the project artifacts: edit the repository URL stated in the mavenOpts line of the 'Build, Test and Publish artifacts to artifact repository' stage.
    The repository defined in the default script provided by Talend is the Nexus snapshots repository.

    Example

    • mavenOpts: '-Dlicense.path=/home/talend/talend_studio/license -Dupdatesite.path=${UPDATESITE_URL} -DaltDeploymentRepository=snapshots::default::http://nexus:8081/repository/snapshots/ -Xms1024m -Xmx3096m')

      (Unix) allows you to deploy artifacts into a Nexus snapshots repository (for projects under development and artifacts with a -SNAPSHOT version). You need to specify your own artifact repository URL.

    • mavenOpts: '-Dlicense.path=C:/Talend/talend_studio/license -Dproduct.path=C:/Talend/talend_studio -Dgeneration.type=local -DaltDeploymentRepository=releases::default::http://nexus:8081/repository/releases/ -Xms1024m -Xmx3096m')
      (Windows) allows you to deploy artifacts into a Nexus releases repository (for stable release artifacts in a Production environment). You need to specify your own artifact repository URL.
      Note: The Talend CommandLine server mode generation type is deprecated, it is recommended to use the -Dupdatesite.path parameter in order to automatically download and install Talend CommandLine at build time or to use the local generation type.
  4. To define the Maven phase you want to achieve: make sure the phases stated in the 'Build, Test and Publish artifacts to artifact repository and 'Push to a Docker Registry' stages are the one you want to perform.
    For more information on the Maven phases, see the Maven documentation.
    Tip: All build profiles (-Pdocker, -Pnexus, etc.) are listed in the parent pom.xml file of your project. Some default parameters, like the docker image name or the Open JDK name, can also be overwritten in this file.

    Example

    • sh "mvn -f $PROJECT_GIT_NAME/poms/pom.xml clean deploy -Pnexus -fn -e -pl jobs/routes${TYPE}/${ARTIFACT}_${VERSION} -am"
      (Unix) allows you to take the packaged route as a jar or .zip files and deploy it to the Nexus repository of your choice.
    • bat "mvn -f $PROJECT_GIT_NAME/poms/pom.xml deploy -Pdocker -fn -e -pl jobs/process${TYPE}/${ARTIFACT}_${VERSION}"
      (Windows) allows you to take the compiled code, package it as a Docker image and deploy it to the registry of your choice.

      For examples of filters you can apply to the execution of your project items, see Filter the execution of your project on selected artifacts.

  5. To define the Docker registry in which you want to deploy the project artifacts: make sure that the Docker credentials stated in the mavenOpts line of the 'Push to a Docker registry' stage point to the credentials you have previously stored in Jenkins.

    Example

    mavenOpts: '-Dcommandline.skip=true -Dlicense.path=${LICENSE} -Dupdatesite.path=${UPDATESITE_URL} -Ddocker.push.registry=registry.hub.docker.com/${env.Dusername} -Ddocker.push.username=${env.Dusername} -Ddocker.push.password=${env.Dpassword} -Xms1024m -Xmx3096m')
    allows you to deploy artifacts as the Docker image you have previously defined in the Docker registry of your choice. You need to specify the Docker registry credentials refer to the credentials you have previously stored in Jenkins.
    Note: The -Dcommandline.skip=true parameter can only be used if you have previously generated your artifacts using Talend CommandLine.
  6. Click Save to take your changes into account.
Troubleshooting:

Troubleshooting:

If you get the following error while trying to publish ESB features:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (deploy-file) on project XXX-feature: 
*The parameters 'url' for goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file are missing or invalid*

Try adding these parameters to the Maven options for release artifacts:

-Dproject.distributionManagement.repository.url=http://localhost:8081/repository/releases/
-Dproject.distributionManagement.repository.id=releases

Or the following parameters for snapshot artifacts:

-Dproject.distributionManagement.snapshotRepository.url=http://localhost:8081/repository/snapshots/
-Dproject.distributionManagement.snapshotRepository.id=snapshots