Adapting the pipeline script to deploy to your artifact repository and to Docker at the same time

Talend Software Development Life Cycle Best Practices Guide

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

If you know your project artifacts are valid and ready to be published, you might want to edit the pipeline script provided by Talend to deploy the artifacts of a project both to an artifact repository (Nexus for example) and to a Docker registry.

Warning: Only Data Integration and Big Data artifacts can be published to Docker. Publishing ESB artifacts (Routes or Data Services) to Docker is not supported yet.

Procedure

  1. Open the Talend_Pipeline configuration page and go to the Script editor.
  2. To deploy the artifacts , replace the 'Build, Test and Publish artifacts to artifact repository' and 'Push to a Docker registry' stages defined in the default script provided by Talend with the following unique stage.
    stage ('Push to artifact repository and Docker) {
    	withCredentials([usernamePassword(credentialsId: 'docker', usernameVariable: 'Dusername', passwordVariable: 'Dpassword')]) {
    	// Docker credentials stored in Jenkins Credentials
        withMaven(
    	    maven: 'M3', 
    	    mavenSettingsConfig: 'maven-file',
    	    mavenOpts: "-Dproduct.path=C:/XXXCommandLine_pathXXX -Dgeneration.type=local -DaltDeploymentRepository=releases::default::http://XXX:8081/repository/XXX/ -Ddocker.push.registry=XXX -Ddocker.push.username=${env.Dusername} -Ddocker.push.password=${env.Dpassword} -Xms1024m -Xmx3096m") {
                
        // Run the maven build    
        sh "mvn -f $PROJECT_GIT_NAME/poms/pom.xml deploy -Pnexus -Pdocker -e -pl jobs/process${TYPE}/${ARTIFACT}_${VERSION} -am -Dtalend.docker.name=${env.IMAGE_NAME}"
            }
        }
    }

    allows you to deploy the filtered artifact to both Nexus and Docker. You need to specify your own path to the Talend Studio installation directory as well as the Nexus repository and Docker registry in which you want to deploy your artifacts. The Docker credentials refer to the credentials you have previously stored in Jenkins.

    Note: The example is adapted for Unix environments. If you are using Windows, replace sh with bat in the example.
  3. Click Save to take your changes into account.