Adapting the pipeline script to deploy to your artifact repository and to Docker at the same time - 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
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.

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.

    Example

    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: "-Dlicense.path=${LICENSE} -Dupdatesite.path=${UPDATESITE_URL} -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 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.