From 0fedb4342026fb77524365cbce4e763c1bfbae44 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 9 Jul 2019 21:26:11 +0200
Subject: [PATCH] [Jenkins] Move push docker images to own subjob.

Docker in Docker is not possible with our current images.
Reverted back to previous setup.
---
 Jenkinsfile | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 020f842003e..f20853c31d3 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -169,19 +169,6 @@ pipeline {
                        'known_hosts" build/docs/. ' +
                        'www-data@jenkins:/var/www/doxygen.opengeosys.org'
                   }
-                  // Push Docker Images
-                  dir('scripts/docker') {
-                    def gccImage = docker.build("ogs6/gcc:latest", "-f Dockerfile.gcc.full .")
-                    def gccGuiImage = docker.build("ogs6/gcc:gui", "-f Dockerfile.gcc.gui .")
-                    def clangImage = docker.build("ogs6/clang:latest", "-f Dockerfile.clang.full .")
-                    withCredentials([usernamePassword(credentialsId: 'docker-hub-credentials',
-                      passwordVariable: 'pw', usernameVariable: 'docker_user')]) {
-                        sh 'echo $pw | docker login -u $docker_user --password-stdin'
-                        gccImage.push()
-                        gccGuiImage.push()
-                        clangImage.push()
-                    }
-                  }
                 }
               }
             }
@@ -681,6 +668,30 @@ pipeline {
             }
           }
         }
+        // ********************* Push Docker Images ***************************
+        stage('Push Docker Images') {
+          when {
+            beforeAgent true
+            environment name: 'JOB_NAME', value: 'ufz/ogs/master'
+          }
+          agent { label 'docker'}
+          steps {
+            script {
+              dir('scripts/docker') {
+                def gccImage = docker.build("ogs6/gcc:latest", "-f Dockerfile.gcc.full .")
+                def gccGuiImage = docker.build("ogs6/gcc:gui", "-f Dockerfile.gcc.gui .")
+                def clangImage = docker.build("ogs6/clang:latest", "-f Dockerfile.clang.full .")
+                withCredentials([usernamePassword(credentialsId: 'docker-hub-credentials',
+                  passwordVariable: 'pw', usernameVariable: 'docker_user')]) {
+                    sh 'echo $pw | docker login -u $docker_user --password-stdin'
+                    gccImage.push()
+                    gccGuiImage.push()
+                    clangImage.push()
+                }
+              }
+            }
+          }
+        }
         // *************************** Post ************************************
         stage('Post') {
           agent { label "master"}
-- 
GitLab