diff --git a/CAL/Docker/Jenkinsfile b/CAL/Docker/Jenkinsfile index 0c1cc2dc8fd623481fc98728b8ba9e2ccc361b62..7817a3a5d4f31cc5664980f19b4d5eff5b08327e 100644 --- a/CAL/Docker/Jenkinsfile +++ b/CAL/Docker/Jenkinsfile @@ -4,35 +4,40 @@ pipeline { } environment { LOFAR_REGISTRY_URL = "http://nexus.cep4.control.lofar:18080" - LOFAR_TAG = "${env.BUILD_NAME}-${env.BUILD_NUMBER}" + LOFAR_REGISTRY = "nexus.cep4.control.lofar:18080" + LOFAR_TAG = "${env.BRANCH_NAME}-${env.BUILD_NUMBER}" } stages { stage('Build base docker file') { steps { script{ - with dir('CAL/Docker/HolographyBase'){ - def image = docker.build('holography-base') - image.tag(env.LOFAR_TAG) + dir('CAL/Docker/HolographyBase'){ + name = docker.build("holography-base").tag(env.LOFAR_TAG) withDockerRegistry(credentialsId: 'nexus', url: env.LOFAR_REGISTRY_URL) { - image.push() + tag_and_push(name, env.LOFAR_REGISTRY) } } + } } } stage('Build build docker file') { steps { script{ - with dir('CAL/Docker/HolographyBuild'){ - def image = docker.build('holography-build') - image.tag(env.LOFAR_TAG) + name = docker.build("holography-build", '-f CAL/Docker/HolographyBuild/Dockerfile .') + .tag(env.LOFAR_TAG) withDockerRegistry(credentialsId: 'nexus', url: env.LOFAR_REGISTRY_URL) { - image.push() - } + tag_and_push(name, env.LOFAR_REGISTRY) } } } } } +} + + +def tag_and_push(image_name, registry){ + sh "docker tag $image_name $registry/$image_name" + sh "docker push $registry/$image_name" } \ No newline at end of file